MATLAB: How to solve a system of differential equations where one equation contains the answer to another

differential equationsMATLAB

I have the following system of differential equations that shall be solved
where are constants, I am looking for a way to deal with the fact that dot and Ω dot are dependant on eachother. I have tried implementing the ode45 function but I did not get a logical result.

Best Answer

If you have the Symbolic Math Toolbox, let it do the ‘heavy lifting’:
syms omegax(t) omegay(t) omegas Omega(t) epsilon sigma alphas t Y
Eqns = [diff(omegax) == omegay*alphas + omegas*Omega*epsilon
diff(omegay) == omegax*alphas - diff(Omega)*epsilon
diff(Omega) == -diff(omegay) - Omega*sigma];
[VF,Subs] = odeToVectorField(Eqns)
Eqnsfcn = matlabFunction(VF, 'Vars',{t,Y,alphas,omegas,sigma,epsilon})
producing this system:
VF =
-(alphas*Y[2] + epsilon*sigma*Y[3])/(epsilon - 1)
alphas*Y[1] + epsilon*omegas*Y[3]
(alphas*Y[2] + sigma*Y[3])/(epsilon - 1)
Subs =
omegay
omegax
Omega
and anonymous function to use with the numeric ODE solvers (slightly edited):
Eqnsfcn = @(t,Y,alphas,omegas,sigma,epsilon) [-(alphas.*Y(2)+epsilon.*sigma.*Y(3))./(epsilon-1.0);alphas.*Y(1)+epsilon.*omegas.*Y(3);(alphas.*Y(2)+sigma.*Y(3))./(epsilon-1.0)];
The ‘Subs’ output are the substitutions odeToVectorField made, with ‘omegay’ being ‘Y[1]’ ‘omegax’ being ‘Y[2]’, and ‘Omega’ being ‘Y[3]’.