Hi, I am working on a project to write a simple code that plots the fourier series of any function written inside the code. The code works well with the fourier coefficients of a0, an and bn. But when I want to sum the series with n=1:10, it gives error.
It says:
"Undefined function 'normalizesym' for input arguments of type 'double'. Error in sym/symsum (line 56) if builtin('numel',x) ~= 1, x = normalizesym(x); endError in Fourier_Series (line 31)son=a0+symsum(sym((an.*cos((n*pi*x)/L)+(bn.*sin((n*pi*x)/L)))),n,1,10);"
Note: I am new in matlab programming.
The code I write is here;
syms n x; fun = exp(x); L=1; n=1:10 a0=(1/L)*int(fun,-L,L); an=(1/L)*int(fun*cos((n*pi*x)/L),x,-L,L); bn=(1/L)*int(fun*sin((n*pi*x)/L),x,-L,L); son= a0+symsum(sym((an.*cos((n*pi*x)/L)+(bn.*sin((n*pi*x)/L)))),n,1,10); x=-L:L; plot(x,son) grid on
Best Answer