Solve a system of differential equations with experimental values of one depedent variable.
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello, everybody.
I'm trying to solve this system of differential equations:
and basicaly what I want to do is have a numerically solution of the function introducing experimental data of , for that i used this code where i can solve the problem and fit the curves to finally have the values that I want (theta(1)) and (theta(2)):
function test01
L = 808e-9; %m. Wavelength
hc= 1.986e-25; %W.s.m Planck constant * speed of light.
I = 116e-3; %W/cm^2 initial intensity
function C=kinetics(theta,t)
c0=[0.96437;0];
[T,Cv]=ode45(@DifEq,t,c0);
%
function dC=DifEq(t,c)
dcdt=zeros(2,1);
dcdt(1)= -L*I*theta(1).*(1-theta(2)).*c(1);
dcdt(2)= L*I*theta(1).*theta(2).*c(1);
dC=dcdt;
end
C=Cv;
end
t=[0
66
132
198
264
330
396
462
528
594
660];
c=[0.96437 0.061
0.81894 0.1128
0.71044 0.1568
0.63977 0.1942
0.53643 0.2259
0.46207 0.2529
0.39372 0.2736
0.33552 0.2934
0.2854 0.3101
0.24209 0.3243
0.213 0.3358];
err=[0.04622 0.001
0.03544 0.001
0.02994 0.002
0.03702 0.002
0.01933 0.001
0.02637 0.001
0.03497 0.001
0.0163 0.002
0.02451 0.002
0.0064 0.001
0.01229 0.001];
theta0=[1,1];
[theta,Rsdnrm,Rsd,ExFlg,OptmInfo,Lmda,Jmat]=lsqcurvefit(@kinetics,theta0,t,c);
fprintf(1,'\tRate Constants:\n')
for k1 = 1:length(theta)
fprintf(1, '\t\tTheta(%d) = %8.5f\n', k1, theta(k1))
end
tv = linspace(min(t), max(t));
Cfit = kinetics(theta, tv);
figure(1)
errorbar(t, c(1:11), err(1:11), 'p')
hold on
errorbar(t, c(12:22), err(12:22), 'p')
hold on
hlp = plot(tv, Cfit);
hold off
grid
xlim([-25 700])
ylim([0 1.05])
xlabel('Time')
ylabel('Concentration')
legend(hlp, 'C_1(t)', 'C_2(t)', 'Location','N')
end
but, to have the problem solved, I had to force and put fake values of . For that, I would like to have any suggestion for this problem, I would like to solve the problem introducing the experimental data I have, and have a curve solution of and the best fitting for this two to have the values: and .
For other hand, if you guys can give me an idea for solving a system of differential equations in matlab when that system has two independent variables, like this case:
Thank you so much for your value help!!!!
1 commentaire
Star Strider
le 3 Août 2019
Your system of differential equations are functions of only, not D, so the ‘kinetics’ function is not integrating D but something else that is not explained or described (although it appears to be tangentially related to ), and because of that, ‘c(2)’ never enters the calculation at all. The function is a function of r and λ, neither of which are defined, and is notably not a function of time, and z is not defined.
Other than that, your problem is absolutely straightforward!
More information would definitely be helpful. It remains to be determined if more information would be illuminating.
Réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!