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

조회 수: 1 (최근 30일)
%% 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

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

추가 답변 (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?

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

카테고리

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

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by