Sorry im a beginner, I use "str2func" to plot function, but this dont work. I got "Error using plot Invalid second data argument"
x=0:0.1:3;
fstring='@(x)2.^x';
fplot = str2func(fstring);
plot(app.UIAxes,x,fplot);
but this works :
x=0:0.1:3;
f=2.^x;
plot(app.UIAxes,x,f);
Why wont matlab plot first one ? And how do I solve it? Thanks

 채택된 답변

Steven Lord
Steven Lord 2017년 3월 19일

1 개 추천

You can't plot a function handle, but you can plot the data you receive from evaluating a function handle.
x = 0:0.1:2*pi;
fh = @sin;
plot(x, fh) % will not work
plot(x, fh(x)) % will work

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Annotations에 대해 자세히 알아보기

질문:

2017년 3월 19일

답변:

2017년 3월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by