Using optimization variable with wiener2

I have a problem, listed below, where x is the optimization variable. It essentially corresponds to the filter window in wiener2 (where m=n). The function calculateExtractionSharpness has the wiener2 filter called within.
x0 = 10;
xl = 1;
xu = 100;
nvar = 1;
x = optimvar('x',1,'LowerBound',xl,'UpperBound',xu);
prob = optimproblem;
optimFunc = @(filterWind) calculateExtractionSharpness(chart,filterWind,1);
prob.Objective = optimFunc(x);
options = optimoptions('intlinprog',"Display","iter");
sol = solve(prob,x0,'Options',options)
However, I get an error that states that:
Error using ones
Size inputs must be numeric.
Error in wiener2 (line 48)
localMean = filter2(ones(nhood), g) / prod(nhood);
Error in untitled>extractDisplacementCurve (line 40)
chart = wiener2(chart,[filterWind filterWind]);
Error in untitled>calculateExtractionSharpness (line 86)
curve = extractDisplacementCurve(chart,filterWind,filterOptions);
Error in untitled (line 32)
optimFunc = @(filterWind) calculateExtractionSharpness(chart,filterWind,1);
Is there a way to solve this issue or is optimization not possible with this type of solver?

 採用された回答

Walter Roberson
Walter Roberson 2021 年 8 月 12 日

0 投票

That cannot be done with Optimization Variables; you would need to switch to Solver-Based Optimization.

1 件のコメント

Aditya Chandramohan
Aditya Chandramohan 2021 年 8 月 13 日
Ah makes sense now. Thanks a lot!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeProblem-Based Optimization Setup についてさらに検索

製品

リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by