How to adjust axes created using plot

1 次查看(过去 30 天)
ssmith
ssmith 2021-11-18
评论: Jon 2021-11-19
I have a function that I have plotted on an interval of [-10,10] but I am not sure what the function is that will adjust the axes so there is empty space around the top of the function plot. Here is what I have to plot the function.
g = @(x) sin(x)/x
fplot(g, [-10, 10])
title('The result of fplot')

回答(1 个)

Jon
Jon 2021-11-18
编辑:Jon 2021-11-18
use the ylim command
for example
g = @(x) sin(x)/x
fplot(g, [-10, 10])
title('The result of fplot')
ylim([-2,2])
  3 个评论
ssmith
ssmith 2021-11-18
@Jon I wrote this, but now isnt the space below the function when I should be above the function?
fplot(g, [-10, 10])
title('The result of fplot')
ylim([-1,1])
Jon
Jon 2021-11-19
You can set the limits of the y axis wherever you want. The argument to the ylim function is a two element vector. The first element sets the lower y limit of the plot, the second element sets the upper limit. They don't need to be symmetrical. So if you want just a little space below the plot and more above you could use:
g = @(x) sin(x)./x
fplot(g, [-10, 10])
title('The result of fplot')
ylim([-0.25,1.25])

请先登录,再进行评论。

类别

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

标签

Community Treasure Hunt

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

Start Hunting!

Translated by