MATLAB Answers

0

How can I solve "Transpose on ND array is not defined. Use PERMUTE instead."?

wave_1
ans =
72 16 12
Error using .'
Transpose on ND array is not defined. Use PERMUTE instead.
Error in interp2 (line 131)
V = V.';
Error in wave_1 (line 43)
slp_po_in = interp2(lonx,laty,slp, x_po_in, y_po_in,'linear');
% main code
clear;close all;
% use ncdisp(filename) to discover file contents...
lat=ncread('ds010.0.20130511.20130516.nc','lat');
lon=ncread('ds010.0.20130511.20130516.nc','lon');
slp=ncread('ds010.0.20130511.20130516.nc','slp');
size(slp)
[row, col] = size(slp);
slp_cen = 99999999999.9;
for icen = 1:length(slp)
for jcen = 1:length(slp)
if slp(icen,jcen)<slp_cen
slp_cen = slp(icen,jcen);
i_cen = icen;
j_cen = jcen;
end
end
end
[lonx,laty] = meshgrid(1:1:300,300:-1:1);
i_ceny = laty(i_cen,1);
j_cenx = j_cen;
lonx = lonx - j_cenx;
laty = laty - i_ceny;
%---wavenumber 1---sigma=0.9----r<100km-
rmax = 25;
rmin = 0.5;
thetad=2; %interpolate angle grid
disd =0.5 ; %interpolate grid
for idis = 1:1:((rmax-rmin)/disd+1)
for ith = 1:1:(360/thetad)
x_po_in(ith,idis) = ((idis-1)*disd+rmin)*cos((ith-1)*thetad*pi/180);
y_po_in(ith,idis) = ((idis-1)*disd+rmin)*sin((ith-1)*thetad*pi/180);
end
end
slp_po_in = interp2(lonx,laty,slp, x_po_in, y_po_in,'linear');
for i = 1:size(x_po_in,2)
slp_w1_in(:,i) = fft(slp_po_in(:,i),1,1);
slp_w1_in(:,i) = slp_w1_in(:,i) - sum(slp_w1_in(:,i))/180;
end
hold on
figure
[C1,h1] = contour(x_po_in,y_po_in, slp_po_in);
hold off;

  2 Comments

@Most. Nasrin Zahan: According to the interp2 help the first three input arguments must be matrices. Put these on the lines just before you call interp2, and tell us what they print:
size(lonx)
size(laty)
size(slp)

Sign in to comment.

1 Answer

Answer by Stephen Cobeldick on 13 Aug 2018
Edited by Stephen Cobeldick on 13 Aug 2018
 Accepted Answer

The variable slp has three dimensions. Either:
  • Change slp so that it is a matrix.
  • Change your code to use interp3 or interpn.

  4 Comments

Show 1 older comment
@Most. Nasrin Zahan: I have no idea what your algorithm is, so you will need to think about what exactly you are trying to interpolate: is it really 2D data? Or 3D data? You can choose the interpolation method based on that. Another option might be to use a loop and indexing... but it depends on what the data represents and the algorithm!
My data is 3D. I used sea level pressure data to find out the cyclone centre and FFT wave number 1 to analyse asymmetry.

Sign in to comment.