can someone please help me to figure out whats wrong with my fourier series code ?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Chad Gray
le 8 Avr 2016
Réponse apportée : Star Strider
le 8 Avr 2016
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 commentaires
Réponse acceptée
Star Strider
le 8 Avr 2016
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 commentaires
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!