numpy/matlab compatibility

M

Matt Funk

Hi,

i am fairly new to python. I was wondering of the following is do-able
in python:

1) a = rand(10,1)
2) Y = a
3) mask = Y > 100;
4) Y(mask) = 100;
5) a = a+Y

Basically i am getting stuck on line 4). I was wondering if it is
possible or not with python?
(The above is working matlab code)

thanks
matt
 
S

Steven D'Aprano

Hi,

i am fairly new to python. I was wondering of the following is do-able
in python:

1) a = rand(10,1)
2) Y = a
3) mask = Y > 100;
4) Y(mask) = 100;
5) a = a+Y

Basically i am getting stuck on line 4). I was wondering if it is
possible or not with python?
(The above is working matlab code)

Not everybody here uses Matlab. Considering that this is a Python list,
not a Matlab list, it may be that the only person who understands what
the above code does is you. (Unlikely, but not *that* unlikely.)

If you want us to help you, you should help us by telling us what the
above code does, and what you've tried (if anything), and what error you
get when you try.

Alternatively, you could try a Matlab forum, and ask for help converting
it to Python there, or much more likely to succeed, a specialist numpy
mailing list. You're very likely to find people with experience in both
numpy and Matlab there.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,240
Members
46,828
Latest member
LauraCastr

Latest Threads

Top