MATLAB to Python?
pavlovevidence at gmail.com
Wed Nov 17 09:46:47 CET 2010
On Nov 17, 12:04 am, MATLABdude <matlab.d... at mbnet.fi> wrote:
> Can you, please, try to help me with Python? I try to convert a MATLAB
> program to Python.
> Here are the MATLAB codes:http://pastebin.com/eJetYizvhttp://pastebin.com/0eXTVfyN
> Here is my Python code:http://pastebin.com/jCPdLHx7
> What is wrong with my Python code? The program doesn't produce quite
> the same lambdas as the MATLAB program does. My code probably has lots
> of errors because I'm just learning the basics about Python.
> Thanks for all the help!
I was about to say it was a pretty good looking piece of code, and
probably if anything is wrong it's a typo somewhere.
But then my eye caught something at the last minute:
xx = range(-kappa, h, kappa+1)
Looks like you're treating range arguments as (start,step,stop), same
order as in Matlab. In Python it's (start,stop,step), so you should
be using this:
xx = range(-kappa,kappa+1,h)
Other than that, you might jus have to pepper your scripts with prints
and disps to catch the exact point where the discrepancy occurs.
More information about the Python-list