Adding Linestyle to ezplot in Matlab

조회 수: 8(최근 30일)
Teoman Selcuk 2021년 10월 31일
편집: VBBV 2021년 10월 31일
I want to a dashed -- linestyle for the plotting of the d function. How would i be able to do that and add it to the code?
Code:
syms x
f = inline('x.^2*exp(-x)', 'x');
d = inline('x.^3', 'x')
ezplot(f, [0 10]); hold on
ezplot(d, [0 10])
댓글 수: 1표시숨기기 없음
Walter Roberson 2021년 10월 31일
Why are you using inline() ? inline() has been recommended against since MATLAB R13 (and I do not mean R2013a -- I mean before MATLAB starting numbering by year.)
Why are you using ezplot() instead of fplot() ? Are you using a version of MATLAB from before R2011b, before fplot() ??
You use syms but you do not do anything symbolic. inline() does not use symbolic variables.
You included MATLAB Compiler in your Products, but syms can never be compiled.

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

답변(2개)

KSSV 2021년 10월 31일
x = linspace(0,10) ;
y1 = x.^2.*exp(x) ;
y2 = x.^3 ;
plot(x,y1,'r',x,y2,'b')
댓글 수: 0표시숨기기 이전 댓글 수: -1

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

VBBV 2021년 10월 31일
편집: VBBV 2021년 10월 31일
syms x
f = inline('x.^2*exp(-x)', 'x');
d = inline('x.^3', 'x');
ezplot(f, [0 10]); hold on
L = ezplot(d, [0 10]);
L.LineStyle = '--'; Matlab does not recommend ezplot. Instead use fplot or plot functions. If you are using older versions of Matlab, then you can access its Line properties to add linstyles of your choice.

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

Community Treasure Hunt

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

Start Hunting!