I have this code in MATLAB:
ext = [lat(end, :); lat; lat(1, :)];
lat = [ext(:, end) ext ext(:, 1)];
and I tried to do this in SciPy:
ext = sc.vstack([[lat[-1,:]], [lat], [lat[0,:]]])
lat = sc.vstack([[ext[:]], [ext], [ext[:,0]]])
but it gives me the errors:
ValueError: arrays must have same number of dimensions
and:
return _nx.concatenate(map(atleast_2d,tup),0) –> (in /usr/lib/pymodules… it’s the definition of vstack function)
Where am I going wrong?
You are stacking vertically in
extand horizontally inlat.Try:
EDIT:
The code above will only work if
latis originally a matrix, rather than an array. If that’s not the case, you can convert bylat = sc.matrix(lat). Also note that I eliminated the extra square brackets in the argument tohstackandvstack.