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

19 次查看(过去 30 天)
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