Matrix and array indices
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Jonathan Demmer
am 10 Aug. 2021
Kommentiert: Matt J
am 11 Aug. 2021
Hi all,
I try ti run a loop as described below. However I keep having the same error and I dont understand where it comes from (see below).
Can someone help please?
Index in position 1 is invalid. Array indices must be positive integers or logical values.
Error in read_NC_create_data (line 37) M(i,1) = M(i,1) + u10(j,k,i+delaytime);
close all
clear all
clc
cd ('D:\SEEC\Matt\');
% Era5 folder:
filename = 'june_wind.nc';
% Files in the folder:
ncTime = ncread(filename,'time');
ncLon = ncread(filename,'longitude');
ncLat = ncread(filename,'latitude');
u10 = ncread(filename,'u10');
v10 = ncread(filename,'v10');
% date number into date calendar:
ncDate = datetime(1900,1,1,'Format','dd/MM/yyyy HH:mm:ss') + hours(ncTime);
% n rows according to the number of timesteps from drifter data;
% m columns for data to extract
M = zeros(566,2);
N = xlsread('REEF_for_Matt.xlsx'); % Matrix to compare and select correct data.
N_Lon = N (:,3);
N_Lat = N(:,4);
% n-1 Start of periof of interest:
delaytime = 130;
for i = 1:566 % length number timestep drifter
clear j k
j = N_Lon(i,1);
k = N_Lat(i,1);
M(i,1) = M(i,1) + u10(j,k,i+delaytime);
end
0 Kommentare
Akzeptierte Antwort
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!