Effacer les filtres
Effacer les filtres

Converting 2 symbolic expressions into a function handle

2 vues (au cours des 30 derniers jours)
kalpana
kalpana le 13 Août 2013
I have to solve 2 symbolic expressions num1 = 0 & num2 = 0.
For this , i have given the code like the following ::
syms p q ;
num1 = 3* p^3 + 4*p*q + 5* p^2 + 1; num2 = 4* p^5 + 9*p^3*q + 2* p*q^2 + 2;
fh = matlabFunction(num1, num2)
[x] = fsolve( fh, [1,2] )
When i execute this code, i am getting the following error .
" ??? Input argument "q" is undefined.
Error in ==>
sym.matlabFunction>makeFhandle/@(p,q)deal (p.*q.*4.0+p.^2.*5.0+p.^3.*3.0+1.0,p.*q.^2.*2.0+p.^3.*q.*9.0+p.^5.*4.0+2.0)
Error in ==> fsolve at 248
fuser = feval(funfcn{3},x,varargin{:});
Caused by:
Failure in initial user-supplied objective function evaluation. FSOLVE cannot continue. "
I tried a lot to rectify this error. But, could not get any thing. Please help me if anyone knows how to solve this problem.
Thanks in advance.
--Kalpana

Réponse acceptée

Andrei Bobrov
Andrei Bobrov le 13 Août 2013
syms p q;
num1 = 3* p^3 + 4*p*q + 5* p^2 + 1;
num2 = 4* p^5 + 9*p^3*q + 2* p*q^2 + 2;
f = matlabFunction([num1;num2],'vars',{[p,q]});
out = fsolve(f,[1,2]);
  1 commentaire
kalpana
kalpana le 13 Août 2013
Thank you very much 'Andrei Bobrov' for your answer. I executed the code which you have given. It is working.
Again, Thanks a lot to you. ---Kalpana

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Symbolic Math Toolbox dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by