How to extract values from a function handle in the prompt

조회 수: 5 (최근 30일)
Avishek Mukherjee
Avishek Mukherjee 2021년 8월 8일
댓글: Walter Roberson 2021년 8월 11일
Here is my code:
C1 = chebfun('exp(1i*t)*(2.4633+0.2865*cos(t)-0.2930*sin(t)-0.0378*cos(2*t)-0.0161*sin(2*t)-0.1422*cos(3*t)+0.0078*sin(3*t)-0.0418*cos(4*t)-0.0569*sin(4*t))',[0 2*pi],'trig');
C2 = chebfun('exp(1i*t)*(1.7133+0.2797*cos(t)-0.2480*sin(t)+0.0295*cos(2*t)+0.0460*sin(2*t)-0.1987*cos(3*t)+0.0309*sin(3*t)-0.0017*cos(4*t)+0.0471*sin(4*t))',[0 2*pi],'trig');
[finv]= conformal2(C1,C2,'poly', 'plots');
When I execute the commands and type in finv in the prompt to get my inverse function, the result is:
finv =
function_handle with value:
@(zz)reval(zz,z,f,w)
My question is how to extract finv from the above function handle?

채택된 답변

Walter Roberson
Walter Roberson 2021년 8월 9일
info = functions(finv);
ws = info.workspace{1};
ws.z
ws.f
ws.w
That will show you the variables that were "captured" in the function handle. It will not, however, necessarily show you anything recognizable as a formula.
  댓글 수: 10
Walter Roberson
Walter Roberson 2021년 8월 11일
But I am suspecting that it is a different function handle that is involved. You were at the command prompt, so if it was Z that the error message was about, then you would not have received a traceback line. I suspect Z([]) is going to show the error as well.
You should debug,
dbstop if error
Z([])
and see where it stops. For example perhaps at the location indicated, it is expecting r1 and r2 to be numeric, but instead one of them is a function handle.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Word games에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by