why there are 0's in my matrix?

1 visualización (últimos 30 días)
Charles Gao
Charles Gao el 19 de Nov. de 2020
Comentada: Charles Gao el 19 de Nov. de 2020
I have been woriking on my assignment and i am trying to make a matrix. the code is on the roght hand side. i think i coverd everythings but why there are 0's in my matrix? Doesn't make any sense.
here's my code
N = 5;
A = zeros(2*N+1,2*N+1);
for i = 2:N+1
t(i-1) = i-1;
A(1,1) = N;
A(1,i) = sum(sin(i*t(i-1)));
A(1,i+N) = sum(cos(i*t(i-1)));
for j = 1:N+1
A(i,j) = A(1,j)*A(1,i);
A(i,j+N) = A(1,j+N)*A(1,i);
A(i+N,j) = A(1,j)*A(1,i+N);
A(i+N,j+N) = A(1,j+N)*A(1,i+N);
end
end
  1 comentario
Rik
Rik el 19 de Nov. de 2020
Please post your code as code. You can simply copy-paste, we would have to type in everything by hand. Have a read here and especially here.

Iniciar sesión para comentar.

Respuesta aceptada

Cris LaPierre
Cris LaPierre el 19 de Nov. de 2020
Editada: Cris LaPierre el 19 de Nov. de 2020
You predefine your matrix A as zeros. So when you get to an equation that multiplies the original value in A to create the new value, the result is 0.
A(i,j) = A(1,j)*A(1,i); % When i=2 and j>2, i=3 and j>3, etc.
  1 comentario
Charles Gao
Charles Gao el 19 de Nov. de 2020
That makes a lot of sense! Thank you so much!!!!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Matrix Indexing 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