Alternative to 'eval', 'evalc','feval' etc functions in the Cody solutions

조회 수: 2 (최근 30일)
Swapnali Gujar
Swapnali Gujar 2014년 3월 28일
댓글: Walter Roberson 2014년 3월 28일
Why cody does not allow 'eval', 'evalc','feval' etc functions in the solutions? What is alternative to these functions?
e.g. I need to use:
if f='3*x'
x=0:10;
y=eval(vectorise(f))
so that values of y can be calculated as 3.*x
bt cody does not let us to use functions like eval
What is the alternative?

답변 (1개)

Walter Roberson
Walter Roberson 2014년 3월 28일
str2func() or inline()
  댓글 수: 2
Swapnali Gujar
Swapnali Gujar 2014년 3월 28일
inline() works, but that is also not allowed by Cody. str2func() doesnt work
Walter Roberson
Walter Roberson 2014년 3월 28일
matlabFunction(sym(f))
matlabFunction automatically vectorizes.

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

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by