error while using ezplot
조회 수: 8 (최근 30일)
이전 댓글 표시
Hi, all.
d = x^2 –6*x – 12;
>> ezplot(d)
Error using inlineeval (line 15)
Error in inline expression ==> x.^2 –6.*x – 12
Error: The input character is not valid in MATLAB statements or
expressions.
Error in inline/feval (line 34)
INLINE_OUT_ = inlineeval(INLINE_INPUTS_, INLINE_OBJ_.inputExpr,
INLINE_OBJ_.expr);
Error in ezplotfeval (line 52)
z = feval(f,x(1));
Error in ezplot>ezplot1 (line 469)
[y, f, loopflag] = ezplotfeval(f, x);
Error in ezplot (line 145)
[hp, cax] = ezplot1(cax, f{1}, vars, labels, args{:});
what is the problem here?
댓글 수: 0
답변 (4개)
Geoff Hayes
2014년 6월 6일
The first input to ezplot must e a function handle or a string (see http://www.mathworks.com/help/matlab/ref/ezplot.html for details). Your variable d is neither - are you using the Symbolic Math Toolbox with a previous command like sym x in order to get that command to evaluate successfully?
I was able to plot this function as follows
d = 'x.^2 - 6*x - 12'
ezplot(d)
or as
func = @(x)x.^2 - 6*x - 12
ezplot(func)
Note the addition of the period at x.^2 so that func can evaluate an input vector rather than just single elements.
댓글 수: 0
gh y
2016년 6월 25일
Some versions of MATLAB can plot a function using ezplot(2014b) while another version(newer versions) cant plot the same code and encounters error. however I didnt test using dot before ^ but found out that same code coudnt be run in two different versions.
댓글 수: 0
Walter Roberson
2016년 6월 25일
The problem is that the inline function was defined using en-dash, char(8211), U+2013, instead of regular hyphen or minus, char(45), U+002d
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Function Creation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!