Matlab does not integral the long function

3 vues (au cours des 30 derniers jours)
Xinyu Liu
Xinyu Liu le 12 Nov 2020
Commenté : Ameer Hamza le 12 Nov 2020
I'm running a project and got this function in matlab :
It1= (176567213623879289833666003849645*cos((pi*(15*t - 6392242573992627495/36028797018963968))/180))/316912650057057350374175801344 + (3969*exp(-207/(1000*((391473114645473*cos((pi*(15*t - 6392242573992627495/36028797018963968))/180))/562949953421312 + 4675603322059651/18014398509481984))))/4 + (1552493519019511649*(1 - ((391473114645473*cos((pi*(15*t - 6392242573992627495/36028797018963968))/180))/562949953421312 + 4675603322059651/18014398509481984)^2)^(1/2))/2251799813685248 + (6035185237487246127*exp(-207/(1000*((391473114645473*cos((pi*(15*t - 6392242573992627495/36028797018963968))/180))/562949953421312 + 4675603322059651/18014398509481984)))*((391473114645473*cos((pi*(15*t - 6392242573992627495/36028797018963968))/180))/562949953421312 + 890695189918650103/2251799813685248000))/45035996273704960 + 2835156233222016111370674437094247/10141204801825835211973625643008
It looks long but only has one variable t, now I want to integral it from 5 to 19, I typed code like this but matlab dose not evaluate it. How do I get a value for this integration?
It2= int(It1,t,5,19)
Thanks!

Réponses (1)

Ameer Hamza
Ameer Hamza le 12 Nov 2020
Modifié(e) : Ameer Hamza le 12 Nov 2020
int() is used for symbolic integration. If MATLAB cannot find a closed-form expression for output, then it will just return the integral expression again. You can find a numerical solution using vpa()
It2 = int(It1,t,5,19);
It2 = vpa(It2);
Another solution is to convert the expression to floating-point format and then use integral() will be faster
It1 = (176567213623879289833666003849645*cos((pi*(15*t - 6392242573992627495/36028797018963968))/180))/316912650057057350374175801344 + (3969*exp(-207/(1000*((391473114645473*cos((pi*(15*t - 6392242573992627495/36028797018963968))/180))/562949953421312 + 4675603322059651/18014398509481984))))/4 + (1552493519019511649*(1 - ((391473114645473*cos((pi*(15*t - 6392242573992627495/36028797018963968))/180))/562949953421312 + 4675603322059651/18014398509481984)^2)^(1/2))/2251799813685248 + (6035185237487246127*exp(-207/(1000*((391473114645473*cos((pi*(15*t - 6392242573992627495/36028797018963968))/180))/562949953421312 + 4675603322059651/18014398509481984)))*((391473114645473*cos((pi*(15*t - 6392242573992627495/36028797018963968))/180))/562949953421312 + 890695189918650103/2251799813685248000))/45035996273704960 + 2835156233222016111370674437094247/10141204801825835211973625643008;
It1 = matlabFunction(It1)
It1 = integral(It1, 5, 19)
  2 commentaires
Xinyu Liu
Xinyu Liu le 12 Nov 2020
Thank you!
Ameer Hamza
Ameer Hamza le 12 Nov 2020
I am glad to be of help!!!

Connectez-vous pour commenter.

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by