use vpasolve's engine without vpasolve

조회 수: 3 (최근 30일)
nathan blanc
nathan blanc 2021년 3월 7일
댓글: nathan blanc 2021년 3월 10일
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

채택된 답변

Steven Lord
Steven Lord 2021년 3월 7일
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
nathan blanc
nathan blanc 2021년 3월 10일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

John D'Errico
John D'Errico 2021년 3월 7일
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.

카테고리

Help CenterFile Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by