필터 지우기
필터 지우기

Converting 2 symbolic expressions into a function handle

조회 수: 2 (최근 30일)
kalpana
kalpana 2013년 8월 13일
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

채택된 답변

Andrei Bobrov
Andrei Bobrov 2013년 8월 13일
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
kalpana
kalpana 2013년 8월 13일
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

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by