Effacer les filtres
Effacer les filtres

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

1 vue (au cours des 30 derniers jours)
>> 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 ?

Réponse acceptée

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

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Multidimensional Arrays dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by