Index exceeds array bounds
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi
When I run my code, I got the error "Index exceed array bounds. I am not sure what it's mean?
I got it in the line "z{i} = ncread(ncfiles(i).name,'z',[1 1 n],[nx ny 1]);"
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{i} = ncread(ncfiles(i).name,'z',[1 1 n],[nx ny 1]);
zx(:,1:ny) = z{i}(:,ny:-1:1);
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
0 commentaires
Réponses (1)
madhan ravi
le 16 Déc 2018
I am not going to understand what you mean but see the example below:
x=1:10
x(11) % you will get the error INDEX EXCEEDS ARRAY BOUNDS
When you try to access the element of an array than it's existence you will get an error.
0 commentaires
Voir également
Catégories
En savoir plus sur Data Types dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!