Unrecognized function or variable 'x0'.
2 次查看(过去 30 天)
显示 更早的评论
[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 个评论
Image Analyst
2023-5-27
Wasn't this essentially solved here: https://www.mathworks.com/matlabcentral/answers/1973964-unrecognized-function-or-variable-x0#answer_1245444
采纳的回答
Matt J
2023-5-27
编辑:Matt J
2023-5-27
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 个评论
Walter Roberson
2023-5-27
(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.)
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!