MATLAB画梯形,其实思路很简单,先找出四个坐标点,然后点与点之间进行连线,即可画出梯形。MATLAB代码如下:
clc,clear;
x=[0 3 2 0];
y=[0 0 2 2];
line(x,y)
xlim([0,4])
ylim([0,4])
text(0,0,'A','Color','red','Fontsize',14)
text(3,0,'B','Color','red','Fontsize',14)
text(2,2,'C','Color','red','Fontsize',14)
text(0,2,'D','Color','red','Fontsize',14)
运行结果:
再在梯形里面加一些线:
clc,clear;
x=[0 3 2 0];
y=[0 0 2 2];
line(x,y)
xlim([0,4])
ylim([0,4])
text(0,0,'A','Color','red','Fontsize',14)
text(3,0,'B','Color','red','Fontsize',14)
text(2,2,'C','Color','red','Fontsize',14)
text(0,2,'D',&