How can i code a system of ODE with one condition in scilab?

38 Views Asked by At

I have a probleme when i code my system in scilab

Normally i write systems with only ODE like $$ \left \{ \begin{array}{rcl} \frac{dx}{dt}&=&a*x+b \\ \frac{dy}{dt}&=&b*y*x+c*y \end{array} \right.$$

But this time i have also something like that

$$\left \{\begin{array}{rcl} \frac{dx}{dt}&=&a*x+b \\ \frac{dy}{dt}&=&b*y*x+c*y \\ z&=&1-x-y \end{array} \right.$$

For the first sysem i use :

function xdot=func(t,x)

xdot(1)=a*x(1)+b

xdot(2)=b*x(2)*x(1)+c*x(2)

endfunction

But for the secon system this not ive the correct result

function xdot=func(t,x)

xdot(1)=a*x(1)+b

xdot(2)=b*x(2)*x(1)+c*x(2)

xdot(3)=1-xdot(1)-xdot(2)
endfunction

This question is surely basic but impossible to find th answer

Thank you for your help