Hi, I am translating a Matlab code to python and get the following error when the codes reaches the plotting section
Warning (from warnings module): File "C:\Documents and Settings\My Documents\PHYSICS\Wave-eqn.py", line 40 w = (D*v) RuntimeWarning: overflow encountered in multiply Traceback (most recent call last): File "C:\Documents and Settings\My Documents\PHYSICS\Wave-eqn\.py", line 50, in <module> ax.plot_wireframe(x,tdata,data, rstride=10, cstride=10) File "C:\Python32\lib\site-packages\mpl_toolkits\mplot3d\axes3d.py", line 906, in plot_wireframe tylines = [tY[i] for i in cii] File "C:\Python32\lib\site-packages\mpl_toolkits\mplot3d\axes3d.py", line 906, in <listcomp> tylines = [tY[i] for i in cii] IndexError: index out of bounds My code import numpy as np from numpy import * from math import pi from scipy.linalg import toeplitz from scipy.special import cotdg from mpl_toolkits.mplot3d import axes3d import matplotlib.pyplot as plt N = 512 h = 2*np.pi/N x = h*(np.arange(N) + 1) t = 0 dt = h / 4 a = .1 tmax = 15; tplot = .15; nplots = int(round((tmax/tplot))); plotgap = int(around(tplot/dt)); c = a + np.sin(x - 1)**2 v = np.exp(-100 * (x - 1)**2) vold = np.exp(-100 * (x - a*dt - 1)**2) #i = np.arange(1, N) #column = np.hstack([0, .5 * (-1**i) * cotdg(i * h/2)]) #D = toeplitz(column, -column) column = ((0.5*(-1)**arange(1,N+1))*cotdg(arange(1,N+1))*(h/2)); D = toeplitz(column,-column);print(D.shape); k = np.zeros(((nplots,N))); print(v.shape);print(k.shape); data = np.concatenate((v.reshape((512,1)).transpose(), k))#data = np.concatenate((v, k),axis = 1); #data = np.vstack([v,k]); tdata = t; for i in range(1,nplots+1): for n in range(1,plotgap+1): t = t+dt w = (D*v) vnew = vold-2*dt*c*w vold = v v = vnew data[i,:] = v[0,:] tdata = vstack([tdata, t]) fig = plt.figure() ax = fig.add_subplot(111, projection='3d') #X, Y, Z = axes3d.get_test_data(0.05) ax.plot_wireframe(x,tdata,data, rstride=10, cstride=10) plt.show() I looked at the error line and it seems as if the y axes is where the problem is, but I am not seeing why and would appreciate any help. Thank you! -- View this message in context: http://old.nabble.com/IndexError%3A-index-out-of-bounds-tp34098663p34098663.html Sent from the matplotlib - users mailing list archive at Nabble.com. ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users