the program i have written below is showing the following error how can i correct this

조회 수: 1 (최근 30일)
>> a1 = xlsread('raincn.xls');
a2 = a1(1:length(a1),5:28);
a2 = a2';
a2 = a2(:);
for i = 12:length(a2)
k24(i) = a2(i)+ a2(i-1)+ a2(i-2)+ a2(i-3)+ a2(i-4)+ a2(i-5)+ a2(i-6)+ a2(i-7)+ a2(i-8)+ a2(i-9)+a2(i-10)+ a2(i-11)+ a2(i-12)+ a2(i-13)+ a2(i-14)+ a2(i-15)+ a2(i-16)+ a2(i-17)+ a2(i-18) + a2(i-19)+ a2(i-20)+ a2(i-21)+ a2(i-22)+ a2(i-23);
k24 = k24';
end
Subscript indices must either be real positive integers or logicals.
what do i do now ?

채택된 답변

Walter Roberson
Walter Roberson 2018년 6월 5일
For a2(i-23) to be valid, the minimum value for i would have to be 24. Instead the minimum in your for loop is 12, leading to (12-23) = -11 as a subscript.
  댓글 수: 1
OMKAR ACHARJEE
OMKAR ACHARJEE 2018년 6월 5일
ohho that was a horrible mistake...i just overlooked that part after copying it from the previous script bdw thanks man..

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by