Borrar filtros
Borrar filtros

Matrix and array indices

2 visualizaciones (últimos 30 días)
Jonathan Demmer
Jonathan Demmer el 10 de Ag. de 2021
Comentada: Matt J el 11 de Ag. de 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

Respuesta aceptada

Matt J
Matt J el 10 de Ag. de 2021
Presumably your N_Lon and N_Lat values are not positive integers.
  2 comentarios
Jonathan Demmer
Jonathan Demmer el 11 de Ag. de 2021
I checked yesterday and yes it was the problem... thank you for the answer.
Matt J
Matt J el 11 de Ag. de 2021
you're welcome, but please Accept-click the answer to indicate that your problem is resolved.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

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

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by