How to Adjust y axis plot range in Matlab?

后端 未结 2 620
梦如初夏
梦如初夏 2021-01-12 17:26

I need to plot the following functions in matlab

y1=sign(x)
y2=tanh(x)
y3=(x)/(x+1)

The x-range is -5,5 with 0.1 spacing The y-plot range s

2条回答
  •  遥遥无期
    2021-01-12 18:21

    If you only want to set the y-range without setting the x-range you can use

    ylim([-1.5 1.5])
    

    or alternatively axis([-inf inf -1.5 1.5]). I found this from the original MATLAB-source: https://de.mathworks.com/help/matlab/ref/ylim.html

    PS: For trigonometric functions I would recommend to use axis equal to have equally spaced x and y-axis (see MATLAB)

提交回复
热议问题