Filter löschen
Filter löschen

Undefined function 'power' for input arguments of type 'function_handle'. for some Implicit function

15 Ansichten (letzte 30 Tage)
I'm trying to plot a "little bit" complicated Implicit function:
for g=1.5 and f=1;
my code was:
g=1.5; %GN
f=1; %epsilon_1
Fun=@(x,y) sqrt((x.^2-y.^2+g^2-f^2)^2+4*x.*y)+g^2+(g*sqrt(2*(x.^2-y.^2+g^2-f^2+sqrt((x.^2-y.^2+g^2-f^2)^2+4*x.*y))))/(tanh((sqrt(2*(x.^2-y.^2+g^2-f^2+sqrt((x.^2-y.^2+g^2-f^2)^2+4*x.*y)))/(g))))
fimplicit(Fun)
but I got the Error code:
Undefined function 'power' for input arguments of type 'function_handle'.
Can anyone please help me to understand what to do in this case?
  5 Kommentare
Daniel Vainshtein
Daniel Vainshtein am 7 Apr. 2021
Bearbeitet: Daniel Vainshtein am 7 Apr. 2021
Fun = @(x,y) sqrt((x.^2-y.^2+g^2-f^2)^2+4*x.*y)+g^2+(g*sqrt(2*(x.^2-y.^2+g^2-f^2+sqrt((x.^2-y.^2+g^2-f^2)^2+4*x.*y))))/(tanh((1/g)*(sqrt(2*(x.^2-y.^2+g^2-f^2+sqrt((x.^2-y.^2+g^2-f^2)^2+4*x.*y))))))

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Cris LaPierre
Cris LaPierre am 7 Apr. 2021
Bearbeitet: Cris LaPierre am 7 Apr. 2021
I'm not able to recreate the same error message. It would appear the code you have shared here does not match the code you are running that is creating the error. Specifically, no function handle is being raised to a power in your example.
I do get a warning with your example about array inputs. To fix this, use elementwise operators where appropriate
Fun=@(x,y) sqrt((x.^2-y.^2+g^2-f^2).^2+4*x.*y)+g^2+(g*sqrt(2*(x.^2-y.^2+g^2-f^2+sqrt((x.^2-y.^2+g^2-f^2).^2+4*x.*y))))./(tanh((sqrt(2*(x.^2-y.^2+g^2-f^2+sqrt((x.^2-y.^2+g^2-f^2).^2+4*x.*y)))/(g))));
% ^^ ^^ ^^ ^^
I can recreate your error message if I break the equation into smaller equations, and combine them to form the bigger equation. Here, the fix is to include the (x,y) inputs when using the handle.
% Works
g=1.5; %GN
f=1; %epsilon_1
eq1 = @(x,y) x.^2-y.^2+g^2-f^2;
eq2 = @(x,y) sqrt(eq1(x,y).^2+4*x.*y);
Fun = @(x,y) eq2(x,y) + g^2 + g*sqrt(2*(eq2(x,y) + eq1(x,y)))./(tanh(sqrt(2*(eq2(x,y) + eq1(x,y)))/g));
fimplicit(Fun)
% Causes error
eq2 = @(x,y) sqrt(eq1.^2+4*x.*y);
% ^ removed the (x,y) inputs. Now code is trying to square a function handle, resulting in an error.
Fun = @(x,y) eq2(x,y) + g^2 + g*sqrt(2*(eq2(x,y) + eq1(x,y)))./(tanh(sqrt(2*(eq2(x,y) + eq1(x,y)))/g));
fimplicit(Fun)
Warning: Error updating ImplicitFunctionLine.

Undefined function 'power' for input arguments of type 'function_handle'.

Weitere Antworten (0)

Kategorien

Mehr zu Line Plots finden Sie in Help Center und File Exchange

Produkte


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by