why there are 0's in my matrix?

1 visualizzazione (ultimi 30 giorni)
Charles Gao
Charles Gao il 19 Nov 2020
Commentato: Charles Gao il 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 Commento
Rik
Rik il 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.

Accedi per commentare.

Risposta accettata

Cris LaPierre
Cris LaPierre il 19 Nov 2020
Modificato: Cris LaPierre il 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 Commento
Charles Gao
Charles Gao il 19 Nov 2020
That makes a lot of sense! Thank you so much!!!!

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by