I keep getting the "not enough inputs error" and I don't know how to fix it
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
global m1 m2 w1a w1w w1m w2m w2w w2a
m1 = 135;
m2 = 30.3455;
w1a = .220;
w1w = .780;
w1m = .000;
w2m = .202;
w2w = .798;
w2a = .000;
function F = Control_volume_4(x)
global m1 m2 w1a w1w w2m w2w
% x(1) = w1m
% x(2) = w2a
% x(3) = w3a
% x(4) = w3m
% x(5) = w3w
% x(6) = m3
F(1) = w1a + x(1) + w1w;
F(2) = x(2) + w2m + w2w;
F(3) = x(3) + x(4) + x(5) - 1;
F(4) = m1 * w1a + m2 * x(2) - x(6) * x(3);
F(5) = m1 * x(1) + m2 * w2m - x(6) * x(4);
F(6) = m1 * w1w + m2 * w2w - x(6) * x(5);
end
guess4 = zeros(1,6);
answer_CV4 = fsolve(Control_volume_4, guess4);
disp(answer_CV4)
i get the " not enough input arguments " error pointing at the x(1) in the F(1) equation
0 Kommentare
Antworten (2)
Stephen23
am 30 Nov. 2024
Bearbeitet: Stephen23
am 30 Nov. 2024
"i get the " not enough input arguments " error pointing at the x(1) in the F(1) equation"
That error is caused by the fact that you called Control_volume_4 (without any input arguments) rather than providing a function handle to FSOLVE: What you did:
answer_CV4 = fsolve(Control_volume_4, guess4);
% ^^^^^^^^^^^^^^^^ here you *call* the function
What you should have done (as shown in the FSOLVE documentation):
answer_CV4 = fsolve(@Control_volume_4, guess4);
% ^ define a function handle, does not *call* the function
After fixing that you will likely need to fix some other errors. You should also avoid GLOBAL:
m1 = 135;
m2 = 30.3455;
w1a = 0.220;
w1w = 0.780;
w1m = 0.000;
w2m = 0.202;
w2w = 0.798;
w2a = 0.000;
fnh = @(x) Control_volume_4(x,m1,m2,w1a,w1m,w1w,w2a,w2m,w2w);
out = fsolve(fnh, zeros(1,6));
format short G
disp(out)
function F = Control_volume_4(x,m1,m2,w1a,w1m,w1w,w2a,w2m,w2w)
F = nan(1,6);
F(1) = w1a + x(1) + w1w;
F(2) = x(2) + w2m + w2w;
F(3) = x(3) + x(4) + x(5) - 1;
F(4) = m1 * w1a + m2 * x(2) - x(6) * x(3);
F(5) = m1 * x(1) + m2 * w2m - x(6) * x(4);
F(6) = m1 * w1w + m2 * w2w - x(6) * x(5);
end
0 Kommentare
Torsten
am 30 Nov. 2024
Bearbeitet: Torsten
am 30 Nov. 2024
m1 = 135;
m2 = 30.3455;
w1a = .220;
w1w = .780;
w1m = .000;
w2m = .202;
w2w = .798;
w2a = .000;
syms x [6 1];
F(1) = w1a + x(1) + w1w;
F(2) = x(2) + w2m + w2w;
F(3) = x(3) + x(4) + x(5) - 1;
F(4) = m1 * w1a + m2 * x(2) - x(6) * x(3);
F(5) = m1 * x(1) + m2 * w2m - x(6) * x(4);
F(6) = m1 * w1w + m2 * w2w - x(6) * x(5);
xsol = solve(F==0)
double(xsol.x1)
double(xsol.x2)
double(xsol.x3)
double(xsol.x4)
double(xsol.x5)
double(xsol.x6)
0 Kommentare
Siehe auch
Kategorien
Mehr zu Symbolic Math Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!