本文介绍了如何在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中绘制水平和垂直线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-17 21:49
查看更多