Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

I have to solve the following

1 visualización (últimos 30 días)
Corne Lourens
Corne Lourens el 13 de Ag. de 2020
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
F1D=1000;
C1D=9250;
F6D=1000;
F3D=400;
C3D=38000;
F2D=@(F5D)F6D-F5D+F1D;
F5D=@(F4D)F6D+F4D-F3D;
F4D=@(F2D)F1D+F3D-F2D;
C4D=@(C5D)(-KlA2*KEQ2*C5D/(COMAKS2-C5D)+F3D*C3D)/(F4D-KlA2);
C6D=@(C5D)(F5D*C5D-KlA*(C1D-KEQ1*C5D/(COMAKS1-C5D)))/F6D;
dc2D_dt=@(t,C5D)(F5D*C5D+F3D*C3D-F6D*C6D-F4D*C4D)/V2;
dcD_dt=@(t,C2D)(F1D*C1D+F6D*C6D-F2D*C2D-F5D*C5D)/V1;
I have to solve this set of eqautions but not sure how to do it if someone can help me

Respuestas (1)

Dana
Dana el 13 de Ag. de 2020
Doing this with anonymous functions is not the way to go (not to mention, your last two functions, dc2D_dt and dcD_dt, have t as an input, but t doesn't actually show up in the function anywhere).
First, write down (i.e., by hand, in regular math notation) your set of equations in the form f_i(x) = 0, where x is your vector of unknowns, and i = 1,2,...,7 indexes your 7 different equations.
Next, you'll want to write a regular MATLAB function (i.e., not an anonymous function) that takes x as the input and returns the vector f(x) = [f_1(x); f_2(x); ..., f_7(x)] as its output.
Then you'll need to choose a MATLAB solver. There are various options available that each have pros and cons. Programatically, you need to choose between a problem-based approach and a solver-based one. From there, you then need to choose a particular solver.
The most widely applicable of the options is probably the solver-based fsolve (though depending on the structure of your problem, and your preferred programming approach, there may be something else that's preferable). fsolve will attemp to find an x that makes each of the elements of f(x) simultaneously as close to zero as possible.
  2 comentarios
Corne Lourens
Corne Lourens el 13 de Ag. de 2020
the two last eqautions is differential eqautions which is interms of the previous eqautions
Dana
Dana el 13 de Ag. de 2020
That's fine, but the expression defining that anonymous function doesn't actually have a t in it. For example, in
dc2D_dt=@(t,C5D)(F5D*C5D+F3D*C3D-F6D*C6D-F4D*C4D)/V2;
you've defined this anonymous function as having two inputs, t and C5D. But t doesn't actually show up anywhere in that function, so there's no reason to list it as an input. Just write
dc2D_dt=@(C5D)(F5D*C5D+F3D*C3D-F6D*C6D-F4D*C4D)/V2;

Community Treasure Hunt

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

Start Hunting!

Translated by