Why can't a variable holding an equation be used to make a function handle?

1 回表示 (過去 30 日間)
Spencer Kranz
Spencer Kranz 2020 年 2 月 20 日
コメント済み: Spencer Kranz 2020 年 2 月 20 日
%% Test
syms x
eqn(x) = x^2
func = @(x) eqn
func(2)

採用された回答

madhan ravi
madhan ravi 2020 年 2 月 20 日
I would simply use matlabFunction() as sir Walter says but maybe you have the follwing in mind:
func = @(x) eqn(x)
  2 件のコメント
Spencer Kranz
Spencer Kranz 2020 年 2 月 20 日
I just forgot the (x) on the end of eqn. I feel like such an idiot. So much time wasted. ughhh
Spencer Kranz
Spencer Kranz 2020 年 2 月 20 日
thank you though!

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

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2020 年 2 月 20 日
Use matlabFunction()
  2 件のコメント
Walter Roberson
Walter Roberson 2020 年 2 月 20 日
Suppose you were to do
A=1; B=2;
C=A+B;
D = @(A) C
What value would you expect D(0) to have? What value would you expect D(5) to have?
Spencer Kranz
Spencer Kranz 2020 年 2 月 20 日
Thank you!

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

カテゴリ

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

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by