How can I use structs as x input for Matlabs optimization methods?
Show older comments
My functions look like that:
function area_rectangle = area_rectangle(input_variables)
if ~isfield(input_variables,'height') || ~isfield(input_variables,'width')
area_rectangle = NaN;
else
area_rectangle = input_variables.width * input_variables.height;
end
Suppose I want to use one of Matlabs optimization methods, e.g. fmincon, and pass a struct as input. How could I do that?
fmincon(@area_rectangle, input_variables, ...)
Error using fmincon (line 224)
FMINCON requires the following inputs to be of data type double: 'X0'.
Thanks in advance! Carolin
Accepted Answer
More Answers (1)
Categories
Find more on Structures in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!