フィルターのクリア

slp error matlab function

1 回表示 (過去 30 日間)
Ous Chkiri
Ous Chkiri 2021 年 3 月 8 日
編集済み: Ous Chkiri 2021 年 3 月 8 日
I have error on my code.This slp method to minimize function
clear;
clc;
x=[1;1];
dxlb=[-1;-1];
dxub=[1;1];
Tolx=0.01;
TolCon=0.01;
[f,g]=f_SLPclass(x);
[gradf,gradg]=g_SLPclass(x);
coverged=false;
iter=0;
while converged
c=gradf';
a=gradg';
b=-g;
dx=linprog(c,a,b,[],[],dxlb,dxub);
x=x+dx;
[f,g]=f_SLPclass(x);
[gradf,gradg]=g_SLPclass(x);
iter=iter+1;
converged=max(abs(dx)<Tolx)&& max(g)<TolCon;
end
fprintf('\n number of iteration %f\n',iter);
fprintf('\n Optimum Point: (%f,%f,%f,%f,%f)\n',x1,x2,x3,x4,x5);
  2 件のコメント
Matt J
Matt J 2021 年 3 月 8 日
What error?
Ous Chkiri
Ous Chkiri 2021 年 3 月 8 日
Error using SLP>f_SLPclass
Too many output arguments.
Error in SLP (line 8)
[f,g]=f_SLPclass(x);

サインインしてコメントする。

採用された回答

Matt J
Matt J 2021 年 3 月 8 日
編集済み: Matt J 2021 年 3 月 8 日
Your functions f_ and g_SLPclass have missing parts.
function [f,g]=f_SLPclass(x) %return outputs
assert(length(x)==5, "x should be 5 elements long, but instead it is length " + length(x));
xcell=num2cell(x);
[x1,x2,x3,x4,x5]= deal(xcell{:});
f=0.0624*(x1+x2+x3+x4+x5);
g=-1+61/x1^3 +37/x2^3 +19/x3^3 +7/x4^3 +1/x5^3;
end
  6 件のコメント
Matt J
Matt J 2021 年 3 月 8 日
編集済み: Matt J 2021 年 3 月 8 日
Ous Chkiri
Ous Chkiri 2021 年 3 月 8 日
Yes your right Sorry. It gives another error

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAssembly についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by