Unrecognized function or variable 'x0'.

1 回表示 (過去 30 日間)
Bismark
Bismark 2023 年 5 月 27 日
コメント済み: Bismark 2023 年 5 月 29 日
[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
Image Analyst 2023 年 5 月 27 日
Bismark
Bismark 2023 年 5 月 29 日
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 件のコメント
Matt J
Matt J 2023 年 5 月 27 日
You cannot proceed unless you buy the Optimization Toolbox.
Walter Roberson
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 件)

カテゴリ

Help Center および File ExchangeGet 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