Optimization Problem definition the function
Show older comments
Hi everyone,
I am trying to define a nonlinear optimization function with 3 unknown variables which I need to optimize.
The optimization function is very large and needs a for loop to be defined, furthermore there are no contraint.
But I am having difficulty defining the function within the for-loop, what I currently have is:
syms x1
syms x2
syms x3
table = readtable('data.csv');
array = table2array(table);
x = [x1,x2,x3]';
for i=1:100
Afun = @(x)((x(1)*array(i,1)-x(2)*array(i,2)+x(3)*array(i,3))^2);
if i==1
FUN = Afun;
else
FUN = FUN + Afun;
end
end
But I get an error where the functions do not want to add, generally I am not sure if I am approaching this type of problem correctly with this method.
Any thought? Thanks!
Accepted Answer
More Answers (0)
Categories
Find more on Solver Outputs and Iterative Display 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!