没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
1/3/2018 NumPy for MATLAB users – Mathesaurus
http://mathesaurus.sourceforge.net/matlab-numpy.html 1/14
NumPy for MATLAB users
Help
MATLAB/Octave Python Description
doc
help -i % browse with Info
help() Browse help interactively
help help or doc doc help Help on using help
help plot help(plot) or ?plot Help for a function
help splines or doc splines help(pylab) Help for a toolbox/library package
demo Demonstration examples
Searching available documentation
MATLAB/Octave Python Description
lookfor plot Search help files
help help(); modules [Numeric] List available packages
which plot help(plot) Locate functions
Using interactively
MATLAB/Octave Python Description
octave -q ipython -pylab Start session
TAB or M-? TAB Auto completion
foo(.m) execfile('foo.py') or run foo.py Run code from file
history hist -n Command history
diary on [..] diary off Save command history
exit or quit CTRL-D
CTRL-Z # windows
sys.exit()
End session
Operators
MATLAB/Octave Python Description
help - Help on operator syntax
Arithmetic operators
MATLAB/Octave Python Description
a=1; b=2; a=1; b=1 Assignment; defining a number
a + b a + b or add(a,b) Addition
a - b a - b or subtract(a,b) Subtraction
a * b a * b or multiply(a,b) Multiplication
1/3/2018 NumPy for MATLAB users – Mathesaurus
http://mathesaurus.sourceforge.net/matlab-numpy.html 2/14
a / b a / b or divide(a,b) Division
a .^ b a ** b
power(a,b)
pow(a,b)
Power, $a^b$
rem(a,b) a % b
remainder(a,b)
fmod(a,b)
Remainder
a+=1 a+=b or add(a,b,a) In place operation to save array
creation overhead
factorial(a) Factorial, $n!$
Relational operators
MATLAB/Octave Python Description
a == b a == b or equal(a,b) Equal
a < b a < b or less(a,b) Less than
a > b a > b or greater(a,b) Greater than
a <= b a <= b or less_equal(a,b) Less than or equal
a >= b a >= b or greater_equal(a,b) Greater than or equal
a ~= b a != b or not_equal(a,b) Not Equal
Logical operators
MATLAB/Octave Python Description
a && b a and b Short-circuit logical AND
a || b a or b Short-circuit logical OR
a & b or and(a,b) logical_and(a,b) or a and b Element-wise logical AND
a | b or or(a,b) logical_or(a,b) or a or b Element-wise logical OR
xor(a, b) logical_xor(a,b) Logical EXCLUSIVE OR
~a or not(a)
~a or !a
logical_not(a) or not a Logical NOT
any(a) True if any element is nonzero
all(a) True if all elements are nonzero
root and logarithm
MATLAB/Octave Python Description
sqrt(a) math.sqrt(a) Square root
log(a) math.log(a) Logarithm, base $e$ (natural)
log10(a) math.log10(a) Logarithm, base 10
log2(a) math.log(a, 2) Logarithm, base 2 (binary)
exp(a) math.exp(a) Exponential function
Round off
MATLAB/Octave Python Description
round(a) around(a) or math.round(a) Round
1/3/2018 NumPy for MATLAB users – Mathesaurus
http://mathesaurus.sourceforge.net/matlab-numpy.html 3/14
ceil(a) ceil(a) Round up
floor(a) floor(a) Round down
fix(a) fix(a) Round towards zero
Mathematical constants
MATLAB/Octave Python Description
pi math.pi $\pi=3.141592$
exp(1) math.e or math.exp(1) $e=2.718281$
Missing values; IEEE-754 floating point status flags
MATLAB/Octave Python Description
NaN nan Not a Number
Inf inf Infinity, $\infty$
plus_inf Infinity, $+\infty$
minus_inf Infinity, $-\infty$
plus_zero Plus zero, $+0$
minus_zero Minus zero, $-0$
Complex numbers
MATLAB/Octave Python Description
i z = 1j Imaginary unit
z = 3+4i z = 3+4j or z = complex(3,4) A complex number, $3+4i$
abs(z) abs(3+4j) Absolute value (modulus)
real(z) z.real Real part
imag(z) z.imag Imaginary part
arg(z) Argument
conj(z) z.conj(); z.conjugate() Complex conjugate
Trigonometry
MATLAB/Octave Python Description
atan(a,b) atan2(b,a) Arctangent, $\arctan(b/a)$
hypot(x,y) Hypotenus; Euclidean distance
Generate random numbers
MATLAB/Octave Python Description
rand(1,10) random.random((10,))
random.uniform((10,))
Uniform distribution
2+5*rand(1,10) random.uniform(2,7,(10,)) Uniform: Numbers between 2 and 7
rand(6) random.uniform(0,1,(6,6)) Uniform: 6,6 array
randn(1,10) random.standard_normal((10,)) Normal distribution
剩余12页未读,继续阅读
资源评论
white_Learner
- 粉丝: 1186
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于matlab主成分分析图像压缩重建系统代码14
- C语言《基于AT89C52单片机搭建的PID直流电机控制程序,主要用于Proteus电路仿真》+源代码
- C++《基于规划和汽车动力学的自动驾驶项目仿真(基于ROS的自动驾驶项目仿真,使用DWA路径规划算法和双PID控制器)》+源代码
- vos3000客户端2.1.7.03、2.1.8.05、2.1.9.07
- c++《用于船舶控制方法研究的3D船舶运动仿真软件》+源代码
- globalmapper24
- Python 小游戏 (贪吃蛇、五子棋、扫雷、俄罗斯方块)源码.zip
- Map data that can be used for 2D raster map path planning
- 关于电子技术数字电路的芯片模拟.zip
- 普中开发板proteus仿真电路V2.6
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功