can someone please help me to figure out whats wrong with my fourier series code ?
1 次查看(过去 30 天)
显示 更早的评论
i was asked to find the fourier series and it's plot for the graph shown below.
now i have used this code to find ao, an and bn for the fourier series but i'm having a trouble when trying to find the fourier series itself and it's plot it keeps giving me error can you please look at it and help me thank you in advance.
>> syms n t
>>wo = pi;
>>to = 2;
>>n = 1:5;
>>ao = (1/to)*(int(2,t,-1,0)+int(1,t,0,1))
>> an = (2/to)*(int(2*cos(n*wo*t),t,-1,0)+int(1*cos(n*wo*t),t,0,1))
>> bn = (2/to)*(int(2*sin(n*wo*t),t,-1,0)+int(1*sin(n*wo*t),t,0,1))
>> fs = ao/2 + symsum(an*cos(n*wo*t),n,0,inf)+symsum(bn*sin(n*wo*t),n,0,inf)
everything was going just fine untill i reach the fs there's something wrong help please and thanks.
0 个评论
采纳的回答
Star Strider
2016-4-8
You need to do array multiplication here:
q1 = an*cos(n*wo*t)'
q2 = bn*sin(n*wo*t)'
q1 =
0
q2 =
- (2*sin(pi*conj(t)))/pi - (2*sin(3*pi*conj(t)))/(3*pi) - (2*sin(5*pi*conj(t)))/(5*pi)
Note the transpose (') operator. Since this is your assignment, I leave the rest to you.
However, using symsum is probably not the way you want to go, since that function is intended to provide analytic summations of symbolic expressions, not the sort of summation you’re doing here. The solution seems simpler than that to me.
0 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!