Error: Invalid use of operator with nc files
Show older comments
Hi
I have a code where i run a couple of nc-files. I have make a for loop so I can run it over all the time steps and for all the longitudes and latitudes.
But I got an error called "Invalid use of opretor in the line called "zx(:,1:ny) = (:,ny:-1:1)z(n);"
I dont know why and what can I do?
I want to find blocking in the northern hemisphere where I will call if GHGS > 0 or GHGN < -10 there is a blocking. Did I have make a correct if loop?
for i = 1:Nfiles
lon{i} = ncread(ncfiles(i).name, 'longitude'); nx = length(lon{i});
lat{i} = ncread(ncfiles(i).name, 'latitude'); ny = length(lat{i});
time{i} = ncread(ncfiles(i).name, 'time'); nt = length(time{i});
z{i} = ncread(ncfiles(i).name, 'z'); nz = length(z{i});
end
%Midler geopotentialet til et månedsmiddel
zmean = zeros([nx ny]);
blocks = zeros([nx]);
for n = 1:nt
z = ncread(ncfiles(i).name,'z',[1 1 n],[nx ny 1]);
zx(:,1:ny) = (:,ny:-1:1)z(n);
zmean = zmean + zx;
%pcolor(lon,lat,z');
%shading interp
%drawnow
GHGS = (zx(:,[151+[-1 0 1]])-zx(:,[131+[-1 0 1]]))/20;
GHGN = (zx(:,[171+[-1 0 1]])-zx(:,[151+[-1 0 1]]))/20;
for i=1:ny
blocks(i)=blocks(i)+1;
if GHGS > 0;
disp('The point is blocked')
elseif GHGN < -10;
disp('The point is blocked')
end
end
end
1 Comment
Jan
on 20 Dec 2018
Please do not post a question multiple times, because this confuses the readers. See https://www.mathworks.com/matlabcentral/answers/436656-index-exceeds-array-bounds-and-some-other-mistakes
Accepted Answer
More Answers (0)
Categories
Find more on Numbers and Precision in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!