why there are 0's in my matrix?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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
Réponse acceptée
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.
Plus de réponses (0)
Voir également
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!