MATLAB to Python?
MATLABdude
matlab.dude at mbnet.fi
Tue Nov 23 02:24:39 EST 2010
On Nov 22, 11:11 am, Peter Otten <__pete... at web.de> wrote:
> Try numpy.arange() instead:
> >>> numpy.arange(0, 1, .1)
> array([ 0. , 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9])
Thanks! It worked.
What's wrong with the following code?
---8<---8<---8<---
T0_orig = [5, 50, 500, 5000]
for counter in T0_orig:
T0 = (L**2)/(D*pi**2)*counter
amax = T0/kappa
alpha = (10**-6)*amax
lambda_, xx, f = nonhomog_solver(kappa, alpha, nu, nx)
V0 = sqrt( T0_orig*(m**-1) + pi**2 * D/(m*L**2)*lambda_ )
print "V0 = ", V0
print ""
---8<---8<---8<---
Python says:
---8<---8<---8<---
Traceback (most recent call last):
File "nonhomog.py", line 159, in <module>
main()
File "nonhomog.py", line 157, in main
nonhomog(0.2)
File "nonhomog.py", line 152, in nonhomog
V0 = sqrt( T0_orig*(m**-1) + pi**2 * D/(m*L**2)*lambda_ )
TypeError: can't multiply sequence by non-int of type 'float'
---8<---8<---8<---
More information about the Python-list
mailing list