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

arraycos arrayMATLAB

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

Best Answer

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
Related Question