Error: Index exceeds array bounds
Afficher commentaires plus anciens
Hi
I have tried this question before but now the question will be more simplyfied. Sorry for the last!
I have used a for loop to read 9 ncfiles with the same variables but different timesteps (different months. I have not take this part to this question.
%Using cell arrays for my variables
lat = cell(Nfiles, 1);
lon = cell(Nfiles, 1);
time = cell(Nfiles, 1);
z = cell(Nfiles, 1);
%Read my variables from all files
for i = 1:Nfiles
lon{i} = ncread(ncfiles(i).name, 'longitude'); %9x1 cell [360x1 single]...
lat{i} = ncread(ncfiles(i).name, 'latitude'); %9x1 cell [181x1 single]...
time{i} = ncread(ncfiles(i).name, 'time'); %9x1 cell [124x1 int32]... (6 times) [112x1 int 32]... (3 times)
z{i} = ncread(ncfiles(i).name, 'z'); %9x1 cell [360x181x124 int32]... (6 times) [360x181x112x int 32]... (3 times)
end
%Define the lengths (all longitude, all latitudes and all timesteps
nx = length(lon{i}); %nx = 360
ny = length(lat{i}); %ny = 181
nt = length(vertcat(time{:})); %nt = 1080
%Now I want the data for all the timesteps. Not only for the last one like in the i-loop. So I make a for loop all over the timesteps.
for n = 1:nt
z = ncread(ncfiles(i).name,'z',[1 1 n],[nx ny 1]);
zx(:,1:ny) = z(:,ny:-1:1);
zmean = zmean + zx;
end
When I run the code I got the error:
Index exceeds array bounds.
Error in Blocking (line 38)
z = ncread(ncfiles(i).name,'z',[1 1 n],[nx ny 1]);
Please, somone there can help me?
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Introduction to Installation and Licensing dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!