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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Multidimensional Arrays 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by