I want to create a 8×8 matrix and fill in the values using a formula. This is the workflow I have in mind is to create some nested for loop that does this:
- I create a empty matrix A using A = zeros(8,8)
- I create variables p(i) using (pi/16)+(i-1)*(pi/8)
- I create a(i,j) = cos((j-1)*p(i)) to fill in matrix
This is what I have tried:
A = zeros(8,8)for i = 1:8 p(i) = (pi/16)+(i-1)*(pi/8) for i = 1:8 for j = 1:8 A(i,j) = cos((j-1)*p(i))
Thank you
Best Answer