# How can a differential equation be solved, if its constants are in a system of equation relation?

5 visualizaciones (últimos 30 días)
Jani el 24 de Ag. de 2021
Comentada: Star Strider el 24 de Ag. de 2021
So the whole equations are here, but for the sake of simplicity I reduced many of the constants, so I can focus only on the relevant things.
So as far as I can see, chi_b and chi_e are two unkwons in a system of equation. In the equation chi_b(z) there is chi_e and in the equation chi_e there is the avarage of chi_b(z). I can solve this with this script (simplified version):
syms chi_b chi_e
K_be=7
delta_b=4
nu_b=33
eqn1=2*chi_b+3*chi_e+exp(K_be * delta_b / nu_b)==chi_b;
eqn2=3*chi_b+2*chi_e==chi_e;
sol=solve([eqn1,eqn2],[chi_b,chi_e]);
chi_b=sol.chi_b
chi_e=sol.chi_e
And I can solve differential equation with this script: Y(1)=chi_p, Y(2)=T_p
[t,Y]=ode23('diffeq_fv',[0 5],[0;1]);
plot(t,Y(:,1),'+',t,Y(:,2),'o')
function Fv=diffeq_fv(t,Y);
Fv(1,1)=3*Y(1);
Fv(2,1)=-4*Y(1)+3*Y(2);
But the d/dt chi_p diff.eq. inculdes chi_e, and when I write chi_e into the diff equations it doesn't work.
[t,Y]=ode23('diffeq_fv',[0 5],[0;1]);
plot(t,Y(:,1),'+',t,Y(:,2),'o')
function Fv=diffeq_fv(t,Y);
syms chi_b chi_e
K_be=7
delta_b=4
nu_b=33
eqn1=2*chi_b+3*chi_e+exp(K_be * delta_b / nu_b)==chi_b;
eqn2=3*chi_b+2*chi_e==chi_e;
sol=solve([eqn1,eqn2],[chi_b,chi_e]);
chi_b=sol.chi_b
chi_e=sol.chi_e
Fv(1,1)=3*Y(1)*chi_e;
Fv(2,1)=-4*Y(1)+3*Y(2);
and gives me this error message: "Inputs must be floats, namely single or double."
So my quesion is how can a diff equation which includes a system of equation be solved?
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Respuestas (1)

Star Strider el 24 de Ag. de 2021
It is difficult to follow the posted code, so I am not certain what you are doing.
If you want to pass those variables to ‘diffeq_fv’ it will be necessary to pas them as extra parameters:
function Fv=diffeq_fv(t,Y,chi_b,chi_e);
K_be=7
delta_b=4
nu_b=33
eqn1=2*chi_b+3*chi_e+exp(K_be * delta_b / nu_b)==13;
eqn2=3*chi_b+2*chi_e==12;
sol=solve([eqn1,eqn2],[chi_b,chi_e]);
chi_b=sol.chi_b
chi_e=sol.chi_e
Fv(1,1)=3*Y(1)*chi_e;
Fv(2,1)=-4*Y(1)+3*Y(2);
end
See Passing Extra Parameters for details.
The ode23 call then becomes:
[t,Y]=ode23(@(t,Y) diffeq_fv(t,Y,chi_b,chi_e),[0 5],[0;1]);
.
##### 4 comentariosMostrar 2 comentarios más antiguosOcultar 2 comentarios más antiguos
Jani el 24 de Ag. de 2021
Yes I thought of that, solving the chi_b-chi_e system first, and then put them into the diffeq.
However now I see that one of the constant in chi_b, contains the Y(1) (chi_p)
so i dont know if it can be solved at all, but for example here is a simple system of equation:
eqn1=2*chi_b+3*chi_e+3+Y(1)==chi_b;
eqn2=-3*chi_b+2*chi_e+6==chi_e;
and here is the diffeq system:
Fv(1,1)=3*Y(1)*chi_b;
Fv(2,1)=-4*Y(1)+3*Y(2)
Is there a solution for this problem?
Star Strider el 24 de Ag. de 2021
It would seem that it would only be necessary to switch the constants in the differential equation:
chi_b = 0.292013077080326;
chi_e = -0.876039231240978;
[t,Y]=ode23(@(t,Y) diffeq_fv(t,Y,chi_b,chi_e),[0 5],[0;1]);
figure
plot(t,Y)
grid
function Fv=diffeq_fv(t,Y,chi_b,chi_e);
% K_be=7
% delta_b=4
% nu_b=33
% eqn1=2*chi_b+3*chi_e+exp(K_be * delta_b / nu_b)==13;
% eqn2=3*chi_b+2*chi_e==12;
% sol=solve([eqn1,eqn2],[chi_b,chi_e]);
% chi_b=sol.chi_b
% chi_e=sol.chi_e
Fv(1,1)=3*Y(1)*chi_b;
Fv(2,1)=-4*Y(1)+3*Y(2);
end
Experiment to get different results.
.

Iniciar sesión para comentar.

### Categorías

Más información sobre Robust Control Toolbox en Help Center y File Exchange.

### Community Treasure Hunt

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

Start Hunting!

Translated by