Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
I have to solve the following
조회 수: 1 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
답변 (1개)
Dana
2020년 8월 13일
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
Dana
2020년 8월 13일
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!