How to adjust axes created using plot

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일

1 개 추천

use the ylim command
for example
g = @(x) sin(x)/x
fplot(g, [-10, 10])
title('The result of fplot')
ylim([-2,2])

댓글 수: 3

You should also probably change your function definition to use element by element division using the ./ i.e.
g = @(x) sin(x)./x
so it will handle vector inputs properly
@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])
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])

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

카테고리

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

태그

질문:

2021년 11월 18일

댓글:

Jon
2021년 11월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by