why there are 0's in my matrix?

1 view (last 30 days)
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 Comment
Rik
Rik on 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.

Sign in to comment.

Accepted Answer

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

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!