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?

 采纳的回答

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

更多回答(0 个)

类别

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

产品

版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by