Fourier series
Show older comments
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 Comment
David Young
on 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.
Answers (0)
Categories
Find more on MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!