Index exceeds array bounds
2 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
madhan ravi
2018 年 12 月 16 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!