I would like to create an array of cos*n*x with n=0,1,2,3...N...

3 views (last 30 days)
I would like to create an array of cos*n*x with n=0,1,2,3...N.
My code looks like this but it does not run.
L=51
N=(L-1)/2;
i=0;
for i=0:N
A=(:,i)=cos(i*pi);
end

Accepted Answer

Stephen23
Stephen23 on 3 Dec 2020
Why do you need a loop?
L = 51;
N = (L-1)/2;
A = cos((0:N)*pi)
A = 1×26
1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1

More Answers (0)

Categories

Find more on Multidimensional Arrays in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!