why there are 0's in my matrix?

1 vue (au cours des 30 derniers jours)
Charles Gao
Charles Gao le 19 Nov 2020
Commenté : Charles Gao le 19 Nov 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 commentaire
Rik
Rik le 19 Nov 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.

Connectez-vous pour commenter.

Réponse acceptée

Cris LaPierre
Cris LaPierre le 19 Nov 2020
Modifié(e) : Cris LaPierre le 19 Nov 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 commentaire
Charles Gao
Charles Gao le 19 Nov 2020
That makes a lot of sense! Thank you so much!!!!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by