MATLAB Answers


Numerical Integration of function with many parameters

Asked by JACINTA ONWUKA on 3 Jun 2019
Latest activity Commented on by Star Strider
on 4 Jun 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!


Sign in to comment.

1 Answer

Answer by Star Strider
on 3 Jun 2019
 Accepted Answer

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)
n =
0 316.737643877379


@Torsten —
Thank you! (I was away for a few minutes.)
As always, my pleasure!

Sign in to comment.