Hướng dẫn matlab to python reddit

Sorry for a "I'm new, please hold my hand" type question. I'm looking to replace Matlab with Python and my limited programming experience has been in a university environment, now that I'll be teaching myself I'm wondering if people think it best for someone in my position to get a bunch of books on Python or should I just dive in and learn as I go?

I'll look at getting the Anaconda package but should I be learning the basics of Python first? Or will a lot of the commands and features that are used for whatever python is mostly used for [???] not apply if I was doing Matlab kind of stuff?

I've been put onto the "Python Scientific Lecture Notes", this seems like a good starting point but I expect learning Python will be a big time commitment so any comments from experience of such a switch will be super appreciated. I'm happy to buy a book or two if there are any good ones.

I mostly do linear algebra, and I find python's data structures and syntax to be very cumbersome in comparison to MATLAB's. There are annoying quirks, like for example you can't transpose an np.array that is one-dimensional. A large part of it is my own inexperience, but I often run into problems where the code doesn't do what I expect it because of syntax reasons. A related example to the transpose thing [numpy as np]:

X = np.array[[[0, 1],[1, 0]]]
eval, evec = np.linalg.eig[X]
idx = np.where[eval==1] # find index of the +1 eigenvector
print evec[:,idx[0][0]].shape # [2,] row vector
print evec[:,idx[0]].shape # [2, 1] column vector
print evec[:,idx].shape # [2, 1, 1] column vector

I can understand why it works like that, but it causes constant headaches for me when I simply want to multiply matrices and vectors without caring about which data structure they're represented by. Also, even really basic matrix operations quickly get verbose in python. For example:

MATLAB:

p2 = U*p*U'

Python:

p2 = U.dot[p.dot[U.conj[].T]]]

Matlab is very good at specific applications; e.g., very easy syntax for working with matrices, producing fancy plots easily out of the box while using a math-based notation.

Python generally can do the same amount of fancy math [e.g., numpy/scipy work similarly to matlab's basic environment and work similarly, and matplotlib is decent at making basic matlab style plots], though it does math with a slightly more explicit and verbose syntax [because it wasn't customized to only do matrix math].

Python shines by making it easier to venture outside of everything is an matrix type programming in ways that matlab didn't already write specific toolkits to do. Python also generally makes it easier to define functions and classes, manipulate non-matrix datatypes [e.g., dict, tuple, list, str, set], like how matlab makes matrix syntax easier.

Further, not being proprietary makes it easier to use and share your code with others who may not have paid $2,000 for a Matlab license.

Finally, python is much more popular in the real world. E.g., on github measured by recent pull requests, python is the second most popular language for projects on github [trailing javascript] representing about 17% of active project work, while matlab is the 37th [representing under 0.1%]. Or similarly about 38% of users in stackoverflow survey are familiar with python compared to about 6% for matlab. Or even for "math" problems looking at say project euler python has about 16 times more users.

Hello reddit Python community:

I'm a senior aerospace engineering major who has used MATLAB for about 4 years in college [it's the only "language" taught in our curriculum]. I've heard that Python can do many things MATLAB can so I would like to start learning. However, I see that Python is a very vast and deep language, while I am basically only concerned in the portion of the language that deals with MATLAB stuff [number crunching, analysis, plotting, fitting curves, ODE solver, etc]

So are there any books [I'm a book type of learner] that just covers these parts of Python? I'm fairly experienced with MATLAB so I might not need too basic of a book. When searching on Amazon, there are books dedicated to SciPy, NumPy, IPython...can someone explain the difference between them and which one should I choose?

Thanks all.

Redditors! I need your input on learning python. I've been using Matlab for a number of years now [to consider myself quite proficient] both in school and in industry writing code from data manipulation, to image analysis and data analysis/plotting. After a few too many roadblocks in deploying packages and overall wanting to learn something more robust I have decided to start adopting Python.

I dont want to start with the 'Hello World' examples but would like a decent resource [book or otherwise] that basically says here is what you need to know, the different functions/syntax/capabilities, etc.

I eventually want to start reading Python for Data Analysis [//www.amazon.com/Python-Data-Analysis-Wrangling-IPython/dp/1449319793] to learn numpy, scipy, etc.

Any help in finding a resource or thoughts on starting are appreciated!

-B

Chủ Đề