Numerical integration with many parameters.

조회 수: 1 (최근 30일)
JACINTA ONWUKA
JACINTA ONWUKA 2019년 6월 4일
편집: Torsten 2019년 6월 4일
I will like to have the values of n2 depending on 10 values of Mycp. please i need help with this my code below.
L=1;
T=100;
r=0.03;
I1=0.5;
p=0.005;
epsilon=0.5;
beta=0.1;
rho=0.5;
Mycp=0:1:10;
delta=1-Mycp/100
tau=(1/(beta*(L+delta*p)))*log((L*(I1+delta*p))/(delta*p*(L-I1)));
t05 =(1/(beta*(L+delta*p)))*log((L*(0.05*L+delta*p))/(delta*p*(L-0.05*L)));
I2= (L*delta*p*(exp (beta*(L+delta*p)*t)-1)) ./ (L + delta*p* exp(beta*(L+delta*p)*t));
fun2=@(t,rho,I2,r)rho*I2*exp(-r*t);
n2= integral(@(t)fun2(t,rho,I2,r),t05,tau, 'ArrayValued',1)

채택된 답변

Torsten
Torsten 2019년 6월 4일
편집: Torsten 2019년 6월 4일
function main
L = 1;
T = 100;
r = 0.03;
I1 = 0.5;
p = 0.005;
epsilon = 0.5;
beta = 0.1;
rho = 0.5;
Mycp = 0:1:10;
n2 = zeros(numel(Mycp),1);
for i = 1:numel(Mycp)
delta = 1-Mycp(i)/100;
tau = (1/(beta*(L+delta*p)))*log((L*(I1+delta*p))/(delta*p*(L-I1)));
t05 =(1/(beta*(L+delta*p)))*log((L*(0.05*L+delta*p))/(delta*p*(L-0.05*L)));
I2= @(t)(L*delta*p*(exp (beta*(L+delta*p)*t)-1)) ./ (L + delta*p* exp(beta*(L+delta*p)*t));
fun2 = @(t)rho*I2(t).*exp(-r*t);
n2(i) = integral(fun2,t05,tau);
end
plot(Mycp,n2)
end

추가 답변 (1개)

darova
darova 2019년 6월 4일
You forgot about element-wise operator
delta=1-Mycp./100;
Look also for VECTORIZE

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by