我真的不知道MATLAB,但我可以回答一些人的(假設你有numpy的進口作爲np):
letter2number_map('A') = 1; -> equivalent to a dictionary: {'A':1}
number2letter_map(1) = 'A'; -> equivalent to a dictionary: {1:'A'}
str2num() -> maybe float(), although a look at the docs makes
it look more like eval -- Yuck.
(ast.literal_eval might be closest)
strcmp() -> I assume a simple string comparison works here.
e.g. strcmp(a,b) -> a == b
trace() -> np.trace() #sum of the diagonal
eye() -> np.eye() #identity matrix (all zeros, but 1's on diagonal)
getenv('STRING') -> os.environ['STRING'] (with os imported of course)
[MI_true, ~, ~] = function() -> Probably: MI_true,_,_ = function()
although the underscores could be any
variable name you wanted.
(Thanks Amro for providing this one)
mslice -> ??? (can't even find documentation for that one)
ones() -> np.ones() #matrix/array of all 1's
如果你缺乏matlab爲什麼不給octave或SciLab一個機會? – 2012-07-26 18:06:37
見http://www.scipy.org/NumPy_for_Matlab_Users/ – tacaswell 2012-07-26 18:39:49
相關:http://stackoverflow.com/questions/9845292/converting-matlab-to-python?rq=1 – 2013-08-26 04:38:15