MATLAB Answers

eval and inline function

조회 수: 7(최근 30일)
adem ski
adem ski 27 Nov 2019
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

Stephen Cobeldick
Stephen Cobeldick 27 Nov 2019
@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?

로그인 to comment.

답변 수 (1)

Fangjun Jiang
Fangjun Jiang 27 Nov 2019
f3=inline('1/(sqrt(x^2+y^2))');
x=1/2;
y=5;
f3(x,y)

  댓글 수: 3

adem ski
adem ski 27 Nov 2019
i want use eval
Fangjun Jiang
Fangjun Jiang 27 Nov 2019
str='1/(sqrt(x^2+y^2))';
eval(str)
Guillaume
Guillaume 27 Nov 2019
"i want use eval"
Why? It's the one function that beginners should never use.

로그인 to comment.

이 질문에 답변하려면 로그인을(를) 수행하십시오.


Translated by