Home / plot command in python / MATLAB commands in numerical Python (NumPy) - GitHub …

MATLAB commands in numerical Python (NumPy) - GitHub … - plot command in python

MATLAB commands in numerical Python (NumPy) - GitHub …-plot command in python

MATLAB commands in numerical Python (NumPy) 1
Vidar Bronken Gundersen /mathesaurus.sf.net
MATLAB commands in numerical Python (NumPy)
Copyright c 2006 Vidar Bronken Gundersen
Permission is granted to copy, distribute and/or modify this document as long as the above attribution is kept and the resulting work is distributed under a license identical to this one.
The idea of this document (and the corresponding xml instance) is to provide a quick reference1 for switching from matlab
to an open-source environment, such as Python, Scilab, Octave and Gnuplot, or R for numeric processing and data visualisation.
Where Octave and Scilab commands are omitted, expect Matlab compatibility, and similarly where non given use the generic command.
Time-stamp: 2007-11-09T16:46:36 vidar
1 Help
Desc. matlab/Octave Python R
Browse help interactively doc help() help.start()
Octave: help -i % browse with Info
Help on using help help help or doc doc help help()
Help for a function help plot help(plot) or ?plot help(plot) or ?plot
Help for a toolbox/library package help splines or doc splines help(pylab) help(package='splines')
Demonstration examples demo demo()
Example using a function example(plot)
1.1 Searching available documentation
Desc. matlab/Octave Python R
Search help files lookfor plot help.search('plot')
Find objects by partial name apropos('plot')
List available packages help help(); modules [Numeric] library()
Locate functions which plot help(plot) find(plot)
List available methods for a function methods(plot)
1.2 Using interactively
Desc. matlab/Octave Python R
Start session Octave: octave -q ipython -pylab Rgui
Auto completion Octave: TAB or M-? TAB
Run code from file foo(.m) execfile('foo.py') or run foo.py source('foo.R')
Command history Octave: history hist -n history()
Save command history diary on [..] diary off savehistory(file=".Rhistory")
End session exit or quit CTRL-D q(save='no')
CTRL-Z # windows
2 Operators
Desc. matlab/Octave Python R
Help on operator syntax help - help(Syntax)
1References: Hankin, Robin. R for Octave users (2001), available from http://cran.r-project.org/doc/contrib/R-and-octave-2.txt (accessed 2005.07.24); Martelli, Alex. Python in a Nutshell (O'Reilly, 2003);
Oliphant, Travis. Guide to NumPy (Trelgol, 2006); Hunter, John. The Matplotlib User's Guide (2005), available from http://matplotlib.sf.net/ (accessed 2005.07.31); Langtangen, Hans Petter. Python
Scripting for Computational Science (Springer, 2004); Ascher et al.: Numeric Python manual (2001), available from http://numeric.scipy.org/numpy.pdf (accessed 2005.06.25); Moler, Cleve. Numerical
Computing with MATLAB (MathWorks, 2004), available from http://www.mathworks.com/moler/ (accessed 2005.03.10); Eaton, John W. Octave Quick Reference (1996); Merrit, Ethan. Demo scripts for
gnuplot version 4.0 (2004), available from http://gnuplot.sourceforge.net/demo/ (accessed 2005.07.24); Woo, Alex. Gnuplot Quick Reference (2004), available from http://www.gnuplot.info/docs/gpcard.pdf
(accessed 2005.07.14); Venables & Smith: An Introduction to R (2005), available from http://cran.r-project.org/doc/manuals/R-intro.pdf (accessed 2005.07.25); Short, Tom. R reference card (2005), available
from http://www.rpad.org/Rpad/R-refcard.pdf (accessed 2005.07.24).
MATLAB commands in numerical Python (NumPy) 2
Vidar Bronken Gundersen /mathesaurus.sf.net
2.1 Arithmetic operators
Desc. matlab/Octave Python R
Assignment; defining a number a=1; b=2; a=1; b=1 a b or greater(a,b) a > b
Less than or equal a = b
Not Equal a ~= b a != b or not_equal(a,b) a != b
2.3 Logical operators
Desc. matlab/Octave Python R
Short-circuit logical AND a && b a and b a && b
Short-circuit logical OR a || b a or b a || b
Element-wise logical AND a & b or and(a,b) logical_and(a,b) or a and b a & b
Element-wise logical OR a | b or or(a,b) logical_or(a,b) or a or b a | b
Logical EXCLUSIVE OR xor(a, b) logical_xor(a,b) xor(a, b)
Logical NOT ~a or not(a) logical_not(a) or not a !a
Octave: ~a or !a
True if any element is nonzero any(a)
True if all elements are nonzero all(a)
2.4 root and logarithm
Desc. matlab/Octave Python R
Square root sqrt(a) math.sqrt(a) sqrt(a) a
Logarithm, base e (natural) log(a) math.log(a) log(a) ln a = loge a
Logarithm, base 10 log10(a) math.log10(a) log10(a) log10 a
Logarithm, base 2 (binary) log2(a) math.log(a, 2) log2(a) log2 a
Exponential function exp(a) math.exp(a) exp(a) ea
MATLAB commands in numerical Python (NumPy) 3
Vidar Bronken Gundersen /mathesaurus.sf.net
2.5 Round off
Desc. matlab/Octave Python R
Round round(a) around(a) or math.round(a) round(a)
Round up ceil(a) ceil(a) ceil(a)
Round down floor(a) floor(a) floor(a)
Round towards zero fix(a) fix(a)
2.6 Mathematical constants
Desc. matlab/Octave Python R
= 3.141592 pi math.pi pi
e = 2.718281 exp(1) math.e or math.exp(1) exp(1)
2.6.1 Missing values; IEEE-754 floating point status flags
Desc. matlab/Octave Python R
Not a Number NaN nan
Infinity, Inf inf
Infinity, + plus_inf
Infinity, - minus_inf
Plus zero, +0 plus_zero
Minus zero, -0 minus_zero
2.7 Complex numbers
Desc. matlab/Octave Python R
Imaginary unit i z = 1j 1i i = -1
A complex number, 3 + 4i z = 3+4i z = 3+4j or z = complex(3,4) z

How to set up command prompt for Python in Windows10?Include a ._pth file alongside your executable containing the directories to include. ...If you are loading python3.dll or python37.dll in your own executable, explicitly call Py_SetPath () or (at least) Py_SetProgramName () before Py_Initialize ().Clear and/or overwrite PYTHONPATH and set PYTHONHOME before launching python.exe from your application.More items...