Find optimized x1, x2, x3 for a given y.
Show older comments
Hi,
I have a function like below:
y=x1^2+2*x1*x2+x3^2;
I want to find the values for x1, x2 and x3 for y=2.
How can I do that? I tried with genetic algorithm using 'ga' function but looks like that's not the right one. Can anyone please help me how should I approach or is there any built in function to get that? Thanks in advance.
Accepted Answer
More Answers (1)
Akira Agata
on 2 Dec 2017
Another solution would be to use fsolve function, like:
fun = @(x) x(1)^2+2*x(1)*x(2)+x(3)^2 - 2;
options = optimoptions(@fsolve,'Algorithm','Levenberg-Marquardt');
% Find the solution from the initial point (x1,x2,x3) = (1,2,3)
fsolve(fun,[1,2,3],options)
Categories
Find more on Problem-Based Optimization Setup 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!