⇤ ← Revision 1 as of 2013-04-03 19:36:49
Size: 883
Comment:
|
Size: 1282
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 38: | Line 38: |
== Are you a Matlab user? == The exercise is to plot a sine wave: Matlab/Octave: {{{ >> x=linspace(0,2*pi,100) >> y=sin(x) >> plot(x,y) }}} Python {{{ In [1]: x=linspace(0,2*pi,100) In [2]: y=sin(x) In [3]: plot(x,y) }}} So, it works pretty much the same way! Of course there are some [[http://www.scipy.org/NumPy_for_Matlab_Users| differences]] but many similarities. |
Python Quick Start
Starting the IPython shell
module load python/2.7-ve2 ipython -pylab
loads matplotlib module and enables interactive plotting
module load is a ZMAW specific environment setting! Version 2.7-ve2 is needed for the notebook version (see below).
Quit with CTRL-D
Getting help
help() help modules
list available modules
Features of IPython:
- Command history (up, down)
- Word completion by typing TAB
- System commands through magic functions cd, ls, env, pwd
Access to Unix shell by prefix !, e.g. !ls -s | sort -g
- Debugging and profiling
Program control: run
Print interactive variables who, whos
Are you a Matlab user?
The exercise is to plot a sine wave:
Matlab/Octave:
>> x=linspace(0,2*pi,100) >> y=sin(x) >> plot(x,y)
Python
In [1]: x=linspace(0,2*pi,100) In [2]: y=sin(x) In [3]: plot(x,y)
So, it works pretty much the same way!
Of course there are some differences but many similarities.