How would I use fsolve for 3 unknowns and 3 equations?

조회 수: 23 (최근 30일)
David Magana
David Magana 2022년 5월 27일
댓글: Star Strider 2022년 5월 29일
I'm confused on how to use fsolve when solving for "TT, a_1, b_1" in my code. I'm trying to solve for each of these variables using the 3 equations that are supposed to be in a 3x1 matrix which is set equal to 'equations.' Any help is much appreciated.
clear;clc;format long;
lm1=0; %m
lm2=-0.2; %m
Am=95; %m^2
At=3; %m^2
omega_m=40.2; %1/s
omega_t=228; %1/s
p=1.225; %kg/m^3
w=32000; %N
hm=0.96; %m
lt=6.5; %m
ht=0.72; %m
equations=@(TT a_1 b_1) [lm1*w+hm*w*a_1-1/Qt*sqrt(TT^3/2*p*At)-1/Qm*sqrt(w^3/2*p*Am)*b_1);hm*w*b_1+(ht*TT)+(1/Qm)*sqrt(w^3/2*p*Am)*a_1;1/Qm*sqrt(w^3/2*p*Am)-lt*TT+lm1*w*b_1];
equationsans=fsolve(equations,[1,1,1]');
Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other syntax error. To construct matrices, use brackets instead of parentheses.

채택된 답변

Star Strider
Star Strider 2022년 5월 27일
Provide values for ‘Qt’ and ‘Qm’ and then solve it —
clear;clc;format long;
lm1=0; %m
lm2=-0.2; %m
Am=95; %m^2
At=3; %m^2
omega_m=40.2; %1/s
omega_t=228; %1/s
p=1.225; %kg/m^3
w=32000; %N
hm=0.96; %m
lt=6.5; %m
ht=0.72; %m
Qm = rand
Qm =
0.770819305637386
Qt = rand
Qt =
0.909584161538862
equations=@(TT, a_1, b_1) [(lm1*w+hm*w*a_1-1/Qt*sqrt(TT^3/2*p*At)-1/Qm*sqrt(w^3/2*p*Am)*b_1);hm*w*b_1+(ht*TT)+(1/Qm)*sqrt(w^3/2*p*Am)*a_1;1/Qm*sqrt(w^3/2*p*Am)-lt*TT+lm1*w*b_1];
equationsans=fsolve(@(b)equations(b(1),b(2),b(3)),[1,1,1]')
Solver stopped prematurely. fsolve stopped because it exceeded the function evaluation limit, options.MaxFunctionEvaluations = 3.000000e+02.
equationsans = 3×1
1.0e+06 * 4.838264690667167 0.000000090313456 -0.000279936800090
There was an unpaired parenthesis in the first row of the vector that I completed. That was throwing the error.
.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

태그

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by