[英]How to draw horizontal and vertical lines in MATLAB?
I am currently trying to plot a simple vertical and horizontal lines in MATLAB.我目前正在尝试在 MATLAB 中绘制一条简单的垂直线和水平线。
For instance, I would like to plot the line y=245.例如,我想绘制 y=245 线。 How would I do that?
我该怎么做?
MATLAB's plotting works on a point-by-point basis from the vectors you give. MATLAB 的绘图根据您提供的向量逐点进行。 So to create a horizontal line, you need to varying
x
while keeping y
constant and vice-versa for vertical lines:因此,要创建一条水平线,您需要在保持
y
不变的同时改变x
,对于垂直线,反之亦然:
xh = [0,10];
yh = [245,245]; % constant
xv = [5,5]; % constant
yv = [0,245*2];
plot(xh,yh,xv,yv);
2 simple ways: 2个简单的方法:
plot(0:0.001:1, 25);
line('XData', [0 1], 'YData', [25 25]);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.