MATLAB: Fourier series code in matlab

fourier series

Sir/Mdm i had a fourier equation need to be evaluate to find THD using matlab code but i am not able to solve this summation using matlab. The required equation which is to be evaluated given below.
and the values of cos angles are
9,20,40,60.
The code i had tried is:
clc;
syms p;
k=symsum(((cosd((2*p-1)*10))/(2*p-1)+(cosd((2*p-1)*22))/(2*p-1)+(cosd((2*p-1)*40))/(2*p-1)+(cosd((2*p-1)*61))/(2*p-1))^2,p,1,50);
j=sqrt(k)/3.14;
double(j)
I am always getting 1 as a solution please help to solve this.

Best Answer

The solution estimated in your question seems correct. The following shows a numerical solution. Since the series is converging so, I used 100000 terms. You can check that increasing terms have no significant effect on the final sum.
angles = [9, 20, 40, 60];
s1 = @(k) sum(cosd(angles(:).*k(:).'))./k;
s2 = sqrt(sum(s1(3:2:100000).^2));
den = sum(cosd(angles));
result = s2/den;
Result:
result =
0.097311482007934