如何在MATLAB中绘制水平线和垂直线? [英] How to draw horizontal and vertical lines in MATLAB?

查看:138
本文介绍了如何在MATLAB中绘制水平线和垂直线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试在 MATLAB 中绘制一条简单的垂直和水平线.

I am currently trying to plot a simple vertical and horizontal lines in MATLAB.

例如,我想绘制 y=245 线.我该怎么做?

For instance, I would like to plot the line y=245. How would I do that?

推荐答案

MATLAB 的绘图基于您提供的向量逐点进行.因此,要创建水平线,您需要在保持 y 不变的同时改变 x,垂直线则相反:

MATLAB's plotting works on a point-by-point basis from the vectors you give. So to create a horizontal line, you need to varying x while keeping y constant and vice-versa for vertical lines:

xh = [0,10];
yh = [245,245]; % constant

xv = [5,5]; % constant
yv = [0,245*2];

plot(xh,yh,xv,yv);

这篇关于如何在MATLAB中绘制水平线和垂直线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆