Numerical Integration of function with many parameters

8 vues (au cours des 30 derniers jours)
JACINTA ONWUKA
JACINTA ONWUKA le 3 Juin 2019
Commenté : Star Strider le 4 Juin 2019
Hi, I've been trying to do this code on matlab but keep getting error.
I want to integrate this function fun= @(t,Mycp,L,r)Mycp*L*exp(-r*t) with n= integral(@(t)fun(t,Mycp,L,r),0,100).
The interval t=[0 100]
The parameters are Mycp=[0 10], L=1,r=0.03,
Please help!

Réponse acceptée

Star Strider
Star Strider le 3 Juin 2019
Use the 'ArrayValued' (link) name-value pair:
Mycp = [0 10];
L = 1;
r = 0.03;
fun = @(t,Mycp,L,r)Mycp*L*exp(-r*t);
n = integral(@(t)fun(t,Mycp,L,r),0,100, 'ArrayValued',1)
producing:
n =
0 316.737643877379
  5 commentaires
JACINTA ONWUKA
JACINTA ONWUKA le 4 Juin 2019
Thanks!!
Star Strider
Star Strider le 4 Juin 2019
As always, my pleasure!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Programming 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