matlab思考,MatLab用户学习Python的思考

一个好的开始是这个页面:SciPy getting started,它提供了一个科学工具栈的概述,您可以使用它从Python转向MatLab:特别是库numpy,scipy,matplotlib,以及交互式工作环境IPython。特别是,numpy和matplotlib的设计非常类似于使用MatLab。在NumPy‘s array type augments the Python language with an efficient data structure useful for numerical work, e.g., manipulating matrices. NumPy also provides basic numerical routines, such as tools for finding eigenvectors.

例如在matlab中你可以写eye(3)-diag([1 1],1)

然后回来

^{pr2}$

在Python/numpy中,您可以编写import numpy as np

np.eye(3)-np.diag([1,1],1)

然后回来array([[ 1., -1., 0.],

[ 0., 1., -1.],

[ 0., 0., 1.]])

使用matplotlibyou have full control of line styles, font properties, axes properties, etc, via an object oriented interface or via a set of functions familiar to MATLAB users.

在MatLab中,你可以写下x=linspace(-pi, pi, 100);

plot(x,sin(x))

在Python/numpy/matplotlib中,您可以编写x=np.linspace(-np.pi, np.pi, 100)

import matplotlib.pyplot as plt

plt.plot(x,np.sin(x))

在网络上有很多专为过渡期的人设计的,比如NumPy for Matlab Users。在MATLAB® and NumPy/SciPy have a lot in common. But there are many differences. NumPy and SciPy were created to do numerical and scientific computing in the most natural way with Python, not to be MATLAB® clones. This page is intended to be a place to collect wisdom about the differences, mostly for the purpose of helping proficient MATLAB® users become proficient NumPy and SciPy users. NumPyProConPage is another page for curious people who are thinking of adopting Python with NumPy and SciPy instead of MATLAB® and want to see a list of pros and cons.

您可能还想考虑一下pylab,它将numpy和matplotlib合并到一个名称空间中,这样就不必费心使用上面使用的np和{}前缀。例如,见wikipedia。在

这个站点上有一些标记值得一看:例如numpy,scipy,matplotlib。还有一个question on Python在统计.se你可能会觉得相关。如果您对统计数据感兴趣,或者对表格式数据的读、写和操作感兴趣,那么您将对pandas感兴趣,Python对R's data frame的回答。在

对于C++,它是一种伟大的语言,但与Python的范畴不一样。这不是讨论他们利弊的恰当地方,但简而言之,C++比Python更接近机器,如果你花时间编写高度优化的代码。在Python中,您可以让代码非常快速地工作,将独立的部分粘在一起,并且可以方便地从任何地方读写数据,但是Python代码有时运行得很慢(就像Matlab,如果您在numpy中进行矢量化,它是快的,否则它会被解释并且很慢)。您可能偶尔希望使用Python调用C中定义的函数的能力来加速较慢的Python代码,例如,this question。(我将把visualbasic放在一边,因为它似乎不相关。)

最后,如comments中所述,回答任何细节都需要知道你的需求是什么,不仅仅是你想做什么,而是你想和谁一起做,以及你有多少时间和金钱可以投资。在

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值