use vpasolve's engine without vpasolve

3 views (last 30 days)
I have a function Y=F(X) where x and y are both 1*n vectors. I want to find X such that F(X)=[0,0....0,0]. i tried using fmincon or fminsearch (with the avsolute value of F) but they failed miserably.
one thing that partialy worked was using vpasolve by writing down (for example for n=3):
function Y1=F1(X1,X2,X3)
Y=F([X1,X2,X3])
Y1=Y(1)
end
and similary for F2 F3. then I wrote
syms x y z
vpasolve(0==F1(x,y,z),0==F2(x,y,z),0==F3(x,y,z))
in short, vpasolve worked well but required defining the equations in a weird way.this certainly cannot be used when n=12 for example.
my question is if there is a different function that uses the same engine or a way to access the engine of vpasolve directly. I tried to open vpasolve's source code but couldn't understand it.
would be thankfull for any assistance

Accepted Answer

Steven Lord
Steven Lord on 7 Mar 2021
If you're trying to find a solution of F, neither fminsearch nor fmincon would be my first choices for functions to use. If F returns a symbolic vector I'd use solve from Symbolic Math Toolbox and if it returns a numeric vector I'd use fsolve from Optimization Toolbox (which you have, since you wouldn't have been able to use fmincon if you didn't.)
Can you show us your F function? Without that information it's going to be difficult if not impossible to offer any suggestions.
  1 Comment
nathan blanc
nathan blanc on 10 Mar 2021
Thank you Steven. the function F is very complex, it is part of an object oriented code and calls about 10 objects and another 10 subfunctions. however fsolve did the trick for me. for some reason i didn't notice that this function exsits.

Sign in to comment.

More Answers (1)

John D'Errico
John D'Errico on 7 Mar 2021
You cannot access vpasolve without using vpasolve. There is no way to access the code for vpasolve.
You cannot use fminsearch on a function with 12 variables. It will converge poorly.
You MAY be able to ue fmincon. While you claim that it failed miserably, is is very possible that you did not know how to use it.
If you have vpasolve, one solution may be simply to learn how to write the equations properly. It sounds like you really just don't understand how to do that. The same applies for fsolve.
But as Steve has said, the real question is what are your equations, not some meaningless contrived set. It is difficult to help you lacking that.

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!