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

36 ビュー (過去 30 日間)
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 件のコメント
Daniel Vainshtein
Daniel Vainshtein 2021 年 4 月 7 日
In the Lyx section or in the matlab code?
Daniel Vainshtein
Daniel Vainshtein 2021 年 4 月 7 日
編集済み: Daniel Vainshtein 2021 年 4 月 7 日
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))))))

サインインしてコメントする。

採用された回答

Cris LaPierre
Cris LaPierre 2021 年 4 月 7 日
編集済み: Cris LaPierre 2021 年 4 月 7 日
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'.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by