Fourier series

how to write summation equation in matlab? can i write n ths way?
function [z1,z2,z3,z4,z5]=switching1(x)
fprintf('enter the value of ');
n=input('n');
for i=1:n
z(1)=1-[(2/pi)*symsum((-1)^i(x(i)-(sin(2*x(i))/2))),1,n]
z(n)=(2/pi)*[symsum((sin*(n-1)*x(i))/(n-1)-(sin*(n+1)*x(i))/(n+1)),1,n]
end
z=(z1-0.2)^2+[z(n)]^2;

1 Kommentar

David Young
David Young am 17 Aug. 2011
Your question seems to reveal many misconceptions, and I think you would do well to review the documentation relating to arrays and matrices in MATLAB before trying to fix this code - go through the introductory material in the users' guide. Note in particular that z(1) is not the same as z1.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu MATLAB finden Sie in Hilfe-Center und File Exchange

Tags

Gefragt:

am 17 Aug. 2011

Community Treasure Hunt

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

Start Hunting!

Translated by