필터 지우기
필터 지우기

Matrix and array indices

조회 수: 2 (최근 30일)
Jonathan Demmer
Jonathan Demmer 2021년 8월 10일
댓글: Matt J 2021년 8월 11일
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

채택된 답변

Matt J
Matt J 2021년 8월 10일
Presumably your N_Lon and N_Lat values are not positive integers.
  댓글 수: 2
Jonathan Demmer
Jonathan Demmer 2021년 8월 11일
I checked yesterday and yes it was the problem... thank you for the answer.
Matt J
Matt J 2021년 8월 11일
you're welcome, but please Accept-click the answer to indicate that your problem is resolved.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Calendar에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by