Hi,
I have a problem with an itterative set of differential equations and im not sure how to put them in mat lab.
the three functions are :
u =[0.25*s]/[0.005 + s] ... 1
dxdt = ux ...2
dsdt=-0.42*ux ...3
It starts by inputting s0 into equations 1 as 0.1, and generating a value for u.
This value of u generated is then used in equation 2 to get a new value for x.
Then this is used to get a new s, then s to get a new u and the process is repeated.
This will show me the change in x and s over time.
I started with the m file for u, which worked fine.
But when i tried to put the function in for dxdt into an mfile i couldnt do it.
I was wondering if anyone could provide me any help
Thanks Rem
Thanks!
I dont knw why i didnt see that.
I have been trying to do it for the past couple of days and looking and the help guide but i dont understand how to put it in.
these are the two m files i attempeted
a = [x;s];
x = 0.25*s*x/(0.005+s);
s = 0.45*0.25*s*x/(0.005+s);
or
a = [x;s];
dadt = [0.25*s*x/(0.005+s);0.45*0.25*s*x/(0.005+s]
but i get errors for both,
i understand how to use ode45, (i think with tspan yo etc).
Do you know what i am doing wrong?
Rem
The function to eveulate the derivatives should look someting like:
But you give insufficient information to set up the initial conditions, what are s and x at t=0?Code:function dx=derive(t,x) dx=zeros(size(x)); dx(1)=0.24*x(1)*x(2)/(0.005+x(2)); dx(2)=0.45*0.24*x(1)*x(2)/(0.005+x(2));
CB
Yeah it does plot them against time.
One last question, sorry, can i export this data to something like excel? i know there is a imwrite xml, but is that it?
If there is not too much data and this is not a production process but a one-off I would just cut abd paste the data with maybe a bit of sorting out at the Excel end.
(Type help xxxx at the command prompt if you want to know what xxxx does)
CB
Thanks for all you help, you dont knwo how great it has been! .
I just have one last question, sorry, i promise it will be the last.
The formula for the next stage gets more complicated. So i tried this, but it didnt work :
function dx=i(t,x)
dx=zeros(size(x));
dx(1)=0.177*x(1)*x(2)/(0.005+x(2)) + u;
dx(2)=-0.177*x(1)*x(2)/(0.45*(0.005+x(2)));
function du=i(t,x);
du = 919.5*x(1);
I thought by putting + u then stating u, it would make it simplier, as i keep inputting mistkaes the other way.
Sorry i was not clear.
What i meant was the next stage of my process involes the same equations as above, but with extra terms in.
For example dX/dt now becomes :
dX/dt= uX - FX/V
Where u = 0.177*S/(S+0.005)
F = 0.177*3443*20*exp(t)/(75*0.45)
V = F + 3443
Basically i am subtarcting FX/V from dx(1).
I was wondering if there is a way to do what i have done above.
Where the M file would simply say something like:
----------------------------------------------------
dx(1)=0.177*x(1)*x(2)/(0.005+x(2)) - F*x(1)/V
F = 0.177*3443*20*exp(t)/(75*0.45);
V = F + 3443;
-----------------------------------------------
Is this possible? as when i try to type the code out in full i keep making mistakes and i htought this would simplify it (especially if i change any figures).
(as later the equation becomes even more complex with more terms containing x and s)
Rem