[SciPy-user] array vs matrix, converting code from matlab
gnchen at cortechs.net
Thu Apr 20 08:50:07 CDT 2006
I am also in the same process. And I would like to add one more
In Matlab, for a 3D array or matrix, the indexing is a(i,j,k). In
numpy, it became a[k-1,i-1,j-1]. Is there any way to make it become
a[i-1,j-1,k-1]? Or I am doing something wrong here??
On Apr 20, 2006, at 3:38 AM, David Cournapeau wrote:
> Dear numpy users,
> I am converting some code from matlab to numpy/scipy, but still a
> bit confused by numpy, mostly the array vs matrix issue. Looking at
> scipy website, the matrix type looks the closest to matlab syntax,
> but I
> still have some issues:
> - under matlab, everything, including scalar, are matrices in
> sense. In python, they are not. So, of I want to handle scalar
> case in
> a function which takes arrays, what should I do ? Having special case
> for scalar sounds like a pain, so is asarray/asmatrix the best way to
> handle those cases so my function only deal with array types ?
> - what is the difference between matrix and array, except syntax ?
> If I want to handle both in one function, what is the "best" method ?
> Using one type only (for example matrix), and using asmatrix on all
> arguments accordingly ?
> To convert my matlab code, I was thinking about using asmatrix for
> arguments in all my functions, but I am not sure this is really the
> "right" way. I was hoping some other people would have some experience
> with the same issues, and could give me some general advices
> thank you,
> P.S: it would be great to have this kind of information on scipy
> website; right now, the scipy for matlab users part is a bit
> sparse... I
> am willing to change this once I understand the problem myself, of
> SciPy-user mailing list
> SciPy-user at scipy.net
More information about the SciPy-user