Solving an integration problem at specific time points

1 回表示 (過去 30 日間)
Jennifer Yang
Jennifer Yang 2019 年 11 月 24 日
回答済み: Dinesh Yadav 2019 年 11 月 27 日
Hello,
I am interested in solving this equation below where I have specific time points that correlate with a gp value. I need to solve the integral at specific time points and multiplying that answer with the rest of the equation that also depends on time. In the end, I want to plot how hp2 looks from 0 to 480 at those time points.
I'm not sure how to have the answer of the integral at a specific time point and then use that same time point for the equation outside of the integral.
Any help is greatly appreciated. Thank you.
t = [0 30 60 90 120 180 240 300 360 420 480];
gp = [10.75 9.45 7.963 5.15 7.213 6.725 6.525 6.325 5.988 5.475 5.213];
Rm = 4.44.*(10.^-12);
b1 = 0.0151;
b2 = 0.002;
q2 = 1.85;
alpha2 = 0.01594;
C1 = 1162;
hp2 = 5.38*(10^-10); %hp2(0)
%-------------------------------------------------------------------------%
syms s
for n = 1:11
disp(gp(n))
disp(t(n))
eqn = (Rm.*exp(-(b1+b2).*s))./(1+(q2.*exp(alpha2.*(C1-gp(n)))));
Fint = int(eqn,s,[0 t(n)]);
Fvpa = vpa(Fint);
fiteqn = ((exp((-b1+b2).*t(n)).*hp2))+((exp((-b1+b2).*t(n))).*Fvpa);
figure(1)
plot(t,fiteqn)
endend

回答 (1 件)

Dinesh Yadav
Dinesh Yadav 2019 年 11 月 27 日
Hi, The issue here is vpa gives a symbolic output, to use it with a function like plot,there is a need to convert the output of vpa to lets say double that can be used with plot as t is also of type double by default. I am attaching the file with few changes to your code.
Hope it Helps.

カテゴリ

Help Center および File ExchangeSymbolic Math Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by