Error when run koppen.m function

조회 수: 9 (최근 30일)
Manikandan Sathiyanarayanan
Manikandan Sathiyanarayanan 2022년 1월 9일
I am new to matlab code. i want to run koppen.m function in matlab and i have prepared precipitation data, temperature data and loation data . while running function it throw me an error .i confused with input data whether i prepare data is right or wrong . i will attach file with error and input data .
for isite=1:size(temp,2)
At least one END is missing. The statement beginning here does not have a matching end.
%%%
%months comprised in summer and winter in each hemisphere
if loc(isite,2) >= 0 %northern hemisphere
summ=4:9;
win=[1 2 3 10 11 12];
else %southern hemisphere
summ=[1 2 3 10 11 12];
win=4:9;
end
tann=nanmean(temp(:,isite));
tmin=nanmin(temp(:,isite));
tmax=nanmax(temp(:,isite));
%%%
pann=sum(precip(:,isite));
ps=sum(precip(summ,isite));
error: Index in position 1 exceeds array bounds. Index must not exceed 2.
Error in classKoppen>Koppen (line 79) ps=nansum(precip(summ,isite));

답변 (1개)

Prateekshya
Prateekshya 2023년 9월 26일
Hi Manikandan,
As per my understanding you are getting an "index exceeds array bounds" error. I assume that the logic of your code works perfectly fine and there is some issue in the indexing. You may go through a similar answer for debugging such a case:
I hope this helps!
  댓글 수: 1
Manikandan Sathiyanarayanan
Manikandan Sathiyanarayanan 2023년 9월 26일
thank you so much for your reply. i will try to use that solution that u mentioned

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

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by