Unrecognized function or variable 'x0'.

2 Ansichten (letzte 30 Tage)
Bismark
Bismark am 27 Mai 2023
Kommentiert: Bismark am 29 Mai 2023
[x,fval]=fsolve(@newmintafun1,x0,options)
When i run the command for the code attached, i'm given an error message "Unrecognized function or variable 'x0'"
Kindly spare a moment to check it out for me. Thank you.
  2 Kommentare
Bismark
Bismark am 29 Mai 2023
Yes i couldn't locate the page for the answers that's why i asked again and copied the url to keep. Thank you

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Matt J
Matt J am 27 Mai 2023
Bearbeitet: Matt J am 27 Mai 2023
Relocate the last 2 lines from newmintafun1 and make x0 the correct length.
x0 = [10; 6; 4; 3; 4; 3; 2; 3; 18; 7; 25; 10; 5; 5; 4; 11; 8; 20; 30; 7; 2; 6; 14; 30];
options = optimset('Display','iter')
[x,fval]=fsolve(@newmintafun1,x0,options)
function F = newmintafun1(x)
F =[x(5)/x(12) - ((0.5*(1-0.08)*x(1))/0.349*(1-0.2)*(1-x(4)));
x(12)*(1 - 0.08)*x(1) + x(7) + x(8) + x(15)*x(17) - ((1 - 0.2)*x(5)*x(4)) - (x(10)*x(6))-((1+x(9))*x(8));
x(12)*x(1)-(0.349*0.99*x(17)*x(15)/0.41*(1 - 0.08));
1-(0.99*(x(10) +(1-0.1)));
x(17)-((0.08 - 1)*x(18));
x(6)-(1-0.1)*x(6)-x(7);
x(15)-((1+0.1)*x(16));
x(16)-(12*(x(13)/x(14)));
x(1)-((1-0.8)^(1/0.667)*x(2)^((0.667-1)/0.667) + 0.8^(1/0.667)*x(3)^((0.667-1)/0.667))^(0.667/(0.667-1));
x(2)-((1-0.8)*(x(13)/x(12))^(-0.667)*x(1));
x(3)- (0.8*(x(14)/x(12))^(-0.667)*x(1));
x(12)-(((1-0.8)*(x(13)^(1-0.667)) + 0.8*x(14)^(1-0.667)^(1/(1-0.667))));
x(12)*x(1)-(x(14)*x(3))-(x(13)*x(2));
x(20)-((x(6)^0.33)*(x(4)^0.349)*(x(19)^(1-0.33-0.349)));
x(10)/x(12)-(0.33*(x(23)/x(6)));
x(5)/x(12)-(0.349*(x(23)/x(4)));
x(19)- (x(13)/x(15)*(1-0.33-0.349)*x(23));
x(18)-((1-0.08)*x(19));
x(25)-(((1-5)*(1-5*0.99))/5*x(22)-0.33*0.99*x(25));
x(9)-x(11) + x(25);
x(22)-((x(13)/x(12))^(0.5)*0.2*5*x(10)^(0.33)*x(5)^(0.349)*x(15)^((1-0.33-0.349)));
x(20)-x(1)-x(7)-x(23)-x(21);
x(23)+(1-x(9))*x(8)-0.08*x(1)-0.2*x(5)*x(4) - 0.08*x(18)-x(8);
x(11) - 1/0.99 - 0.5*(x(24)-1)-0.5*(x(23)-4)];
% x0 = [10; 6; 4; 3; 4; 3; 2; 3; 18; 7; 25; 10; 5; 5; 4; 11; 8; 20; 30; 7; 2; 6; 14; 30;];
% options = optimset('Display','iter')
end
  3 Kommentare
Matt J
Matt J am 27 Mai 2023
You cannot proceed unless you buy the Optimization Toolbox.
Walter Roberson
Walter Roberson am 27 Mai 2023
(Though there is a chance that you already own the Optimization Toolbox but have not installed it. Use the Add-On Explorer to search for the toolbox; it will tell you whether you already own it or not.)

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Get Started with MATLAB finden Sie in Help Center und File Exchange

Produkte


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by