fourier series code in matlab
4 次查看(过去 30 天)
显示 更早的评论
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.![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/289981/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/289981/image.png)
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.
0 个评论
采纳的回答
Ameer Hamza
2020-5-3
编辑:Ameer Hamza
2020-5-3
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
8 个评论
Ameer Hamza
2020-5-3
Please check my updated answer. I found that there was a mistake. Now it gives different values.
Ameer Hamza
2020-5-3
You code, also seems correct. Start the sum k limits from 2 instead of 1
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,2,50);
%^ use 2 here
j=sqrt(k)/3.14;
double(j)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Calculus 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!