Adding Linestyle to ezplot in Matlab

2 次查看(过去 30 天)
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
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
KSSV 2021-10-31
x = linspace(0,10) ;
y1 = x.^2.*exp(x) ;
y2 = x.^3 ;
plot(x,y1,'r',x,y2,'b')
Read about plot you can use your desired line style and marker.

rezheen
rezheen 2025-4-8
Doing something like this would solve your dashed line problem:
syms x
f = inline('x.^2*exp(-x)', 'x');
d = inline('x.^3', 'x');
ezplot(f, [0, 10]); hold on
g=ezplot(d, [0, 10]);
set(g,'LineStyle', '--')
But, you might want to adjust the window, maybe add ymin, ymax.
  1 个评论
Walter Roberson
Walter Roberson 2025-4-8
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Mathematics 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by