eval and inline function

4 次查看(过去 30 天)
adem ski
adem ski 2019-11-27
编辑: Stephen23 2019-11-27
clc
clear all
close all
a=0;
b=2;
y=5;
x=1/2;
f3=inline('1/(sqrt(x^2+y^2)');
[f6]=eval(f2)
??? Undefined function or method 'eval' for input arguments of type 'inline'.
  1 个评论
Stephen23
Stephen23 2019-11-27
编辑:Stephen23 2019-11-27
@adem ski: why on earth are you using outdated and almost obsolete inline?
The very start of the inline documentation states
Why are you ignoring the advice of the MATLAB documentation? Your task would be trivial with an anonymous function, do you have a good reason why you cannot use one?
Why on earth do you want to use awful, anti-pattern eval?

请先登录,再进行评论。

回答(1 个)

Fangjun Jiang
Fangjun Jiang 2019-11-27
f3=inline('1/(sqrt(x^2+y^2))');
x=1/2;
y=5;
f3(x,y)
  3 个评论
Fangjun Jiang
Fangjun Jiang 2019-11-27
编辑:Fangjun Jiang 2019-11-27
str='1/(sqrt(x^2+y^2))';
eval(str)
Guillaume
Guillaume 2019-11-27
"i want use eval"
Why? It's the one function that beginners should never use.

请先登录,再进行评论。

类别

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