Problem with integrating Sin to Cos
Afficher commentaires plus anciens
Good day.
I am trying to integrate the following equation but Matlab seems to not integrate Sin to Cos?
Not sure if the error is in my code.
ode = (2/pi) * (int(sin(n*x), 0, pi/2))
ode = (4*sin((n*pi)/4)^2)/(n*pi)
Any help will be appreciated.
Thank you
2 commentaires
Jan
le 3 Avr 2021
Do you get an error message? Then please share it,
Ruwan Badenhorst
le 4 Avr 2021
Réponse acceptée
Plus de réponses (1)
Paul
le 4 Avr 2021
If you just want ode in terms of cos()
>> ode = int(sin(n*x),x,0,pi/2)
ode =
(2*sin((pi*n)/4)^2)/n
>> rewrite(ode,'cos')
ans =
-(2*(cos((pi*n)/4)^2 - 1))/n
The "by hand" solutions is:
>> sol=1/n*(-cos(n*pi/2) + cos(0*n))
sol =
-(cos((pi*n)/2) - 1)/n
Show the two solutions are equal:
>> simplify(ode-sol)
ans =
0
Wrangling ode into the form of sol takes a few steps. Perhaps someone else can do it easier:
>> simplify(combine(rewrite(ode,'cos')))
ans =
-(cos((pi*n)/2) - 1)/n
Catégories
En savoir plus sur Programming dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



