Solving an integration problem at specific time points

1 view (last 30 days)
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

Answers (1)

Dinesh Yadav
Dinesh Yadav on 27 Nov 2019
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.

Categories

Find more on Symbolic Math Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!