Clear Filters
Clear Filters

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

1 view (last 30 days)
>> 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 ?

Accepted Answer

Walter Roberson
Walter Roberson on 5 Jun 2018
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 Comment
OMKAR ACHARJEE
OMKAR ACHARJEE on 5 Jun 2018
ohho that was a horrible mistake...i just overlooked that part after copying it from the previous script bdw thanks man..

Sign in to comment.

More Answers (0)

Categories

Find more on Multidimensional Arrays in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!