How can I use a user define function (.m file) as the prob.objective

5 ビュー (過去 30 日間)
Panya Kansuwan
Panya Kansuwan 2023 年 1 月 25 日
コメント済み: Rik 2023 年 1 月 26 日
I have create .m file function called wear_cal.m with 2 arguments dz1 and dz2. Both are defined in optimvar.
Now I want to minimizae the wear for optimized dz1 and dz2 using my own algorithm to get the value wear without direct expression.
The code is look like this,
prob = optimproblem("Description","B-Spline fit profile")
show(prob)
% Create variables
dz1 = optimvar('dz1','LowerBound',0,'UpperBound',5)
dz2 = optimvar('dz2','LowerBound',0,'UpperBound',5)
show(prob)
wear = wear_cal(dz1,dz2)
prob.Objective = wear;
show(prob)
The error is on how I can express prob.Objective = wear correctly. Please advise
Best regards,
Panya K

回答 (1 件)

Rik
Rik 2023 年 1 月 25 日
From what I can tell reading the documentation, the easiest way would be to use the fcn2optimexpr function.

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by