Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

Getting an "index out of bounds error" in my Matlab program. Help.

1 visualización (últimos 30 días)
Virajan Verma
Virajan Verma el 16 de Oct. de 2018
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
ex(1)=lx/J %%first i term in ex matrix
ex(2)=mx/J %%second j term in ex matrix
ex(3)=nx/J %%third k term in ex matrix
for i=1:8
for j=1:27
N_matrix(i,j)=0;
end
end
for i=1:9
N_matrix(1,i)=N(rem(i-1,3)+1)*ex(i)/3;(ERROR HERE)
end
Attempted to access ex(4); index out of bounds because numel(ex)=3.
Error in practisee2 (line 227)
N_matrix(1,i)=N(rem(i-1,3)+1)*ex(i)/3
  1 comentario
KSSV
KSSV el 16 de Oct. de 2018
@ Virajan Verma It is not fair to ask every step a question in forum. I suggest/ advice you to read basic tutorials of MATLAB which is very easy

Respuestas (1)

KSSV
KSSV el 16 de Oct. de 2018
YOur ex has only three elements..you are trying to access i = 4. So error.
  1 comentario
KSSV
KSSV el 16 de Oct. de 2018
Replace these lines:
for i=1:8
for j=1:27
N_matrix(i,j)=0;
end
end
by simply:
N_matrix = zeros(8,27) ;

La pregunta está cerrada.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by