[SciPy-User] [SciPy-user] ValueError: arrays must have same number of dimensions

surfcast23 surfcast23@gmail....
Thu Jun 28 10:32:47 CDT 2012

```Hi I am trying to translate a Matlab code from Trefethen's Spectral Methods
in MATLAB to Python. I am running into a problem with numpy.concatenate
wanting the arrays to have the same number of dimensions.
Here is part of the Matlab code that I am rewriting

N = 512; h = 2*pi/N; x = h*(1:N); t = 0; dt = h/4;
a = .1;
c = a + sin (x-1).^2;
v = exp(-100*(x-1).^2); vold = exp(-100*(x-a*dt-1).^2);

column = [0 .5*(-1).^(1:N-1).*cot((1:N-1)*h/2)];
D = toeplitz(column,-column);

% Time-stepping by leap frog formula:
tmax = 15; tplot = .15; clf, drawnow, set(gcf,'renderer','zbuffer')
plotgap = round(tplot/dt); dt = tplot/plotgap;
nplots = round(tmax/tplot);
data = [v; zeros(nplots,N)]; tdata = t;

What I am trying in Python

for j in range(1,N):
tmax = 15;
tplot = .15;
h = 2*pi/N;
dt = h/4;
nplots = around(tmax/tplot);
plotgap = around(tplot/dt);
dt = tplot/plotgap;
x = h*arange(1,N);
c = a+np.sin(x-1)**2;
v = exp(-100*(x-1)**2);
vold = exp(-100*(x-a*dt-1)**2);

column = ((0.5*(-1)**arange(1,N-1))*cotdg(arange(1,N-1))*(h/2));
D = toeplitz(column,-column);

k = np.zeros(((nplots,N)));
data = np.concatenate((v, k),axis = 0);
tdata = t;

I have highlighted the vectors in question.
v.shape gives (511,)

k.shape gives (100, 512)

I would appreciate any help with this. Thank you!

--
View this message in context: http://old.nabble.com/ValueError%3A-arrays-must-have-same-number-of-dimensions-tp34086886p34086886.html
Sent from the Scipy-User mailing list archive at Nabble.com.

```