Help with differential equations in matlab ?

Hi , I need help with this excercise : I need to find k(speed constant ) if I know that
dx/dt=k*((a-x)^2) and I have this data :
t <min>=<0,2.5,5.6,9.6,14.6, 21.5,32.5,52.2> and
<a-x><mol/l>=<0.0050,0.0045, 0.0040, 0.0035, 0.0025,0.0020,0.0015>
I have a problem with solving an example in matlab.
<`**matlab-differential equations**`>
I´ve tried next steps:
Command W. :
t=[0 2.5 5.6 9.6 14.6 21.5 32.5 52.2];
x=[0:0.0005:0.0035];
a=0.0050;
c=a-x;
Editor ( my skript):
function dx=f(t,x)
dx=k*.((a-x).^2)
end + Run
Command W. :
tspan=0:0.0005:0.0035;
>> [x,t]=ode45(f,[0:0.0005:0.0035],0)
I don´t know how to find k

1 commentaire

Helena Vesteg
Helena Vesteg le 6 Juin 2021
And I don´t know if steps before are correct , please somebody for help it tooks me 2 days .....

Connectez-vous pour commenter.

Réponses (1)

Sulaymon Eshkabilov
Sulaymon Eshkabilov le 7 Juin 2021

0 votes

You have confused your problem statement and its parameters. Also, there are a few errs.
(1) t=[0 2.5 5.6 9.6 14.6 21.5 32.5 52.2]; x=[0:0.0005:0.0035];
t can be set as a vector, e.g. t = linspace(0, 5, 200) or time range, e.g. t = [0, 5]
(2) Check the initial conditions, x(0) = ???. Because x(0) = 0 does not give any simulation results.
(3) check for k.

4 commentaires

Helena Vesteg
Helena Vesteg le 7 Juin 2021
does it mean that whole my matlab code is wrong ? cause I am hopeless....
No, don't think that way. We all make mistakes and learn. Learning is all about making mistakes and learn from them. Thus, try to solve it again. If you can't get it to run correctly, then you will be helped. Good luck.
Thank you :) . So I changed my (code) steps like :
Comand Window:
t=[0; 2.5; 5.6; 9.6;14.6; 21.5;32.5;52.2]; I put between numbers ; cause I think it means that t is a vector
x=[0;0.0005;0.0035]; I thought that this step is corect because step is h=0.0005
Editor:
function dxdt=f(t,x) % k is unknown parameter
close all
t_range=[0,52.2];
x0=1;
dxdt=k*((0.0050-x).^2)
end
Helena Vesteg
Helena Vesteg le 7 Juin 2021
Modifié(e) : Helena Vesteg le 8 Juin 2021
And next steps are same ....
But I still don´t know how to create matlab code for k ? I realy tried but I solved function without matlab that k is k=x/at*(a-x) (after integration and if t=0 ,x=0 ) and I know results for k but I put it only on paper I have problem with matlab cause I´ve tried too many combinations . Can you help me please to do it right and finish this excercise.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Mathematics dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by