Unrecognized function or variable 'x0'.

[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 个评论

Yes i couldn't locate the page for the answers that's why i asked again and copied the url to keep. Thank you

请先登录,再进行评论。

 采纳的回答

Matt J
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 个评论

This is what pops up when i run
"'fsolve' requires Optimization Toolbox.
Error in newmintafun1 (line 3)
[x,fval]= fsolve(@newmintafun,x0,options)"
How do i proceed from here sir?
You cannot proceed unless you buy the Optimization Toolbox.
(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 个)

类别

帮助中心File Exchange 中查找有关 Get Started with MATLAB 的更多信息

产品

版本

R2023a

标签

Community Treasure Hunt

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

Start Hunting!

Translated by