Borrar filtros
Borrar filtros

Index exceeds array bounds

2 visualizaciones (últimos 30 días)
Jonas Damsbo
Jonas Damsbo el 16 de Dic. de 2018
Respondida: madhan ravi el 16 de Dic. de 2018
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

Respuestas (1)

madhan ravi
madhan ravi el 16 de Dic. de 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.

Categorías

Más información sobre Data Types en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by