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

1 visualización (últimos 30 días)
>> 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 ?

Respuesta aceptada

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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Dates and Time en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by