MATLAB中的rectangle函数用于在当前图形窗口中绘制矩形。其使用格式如下:

rectangle('Position',[x,y,w,h]) rectangle('Position',[x,y,w,h],'LineWidth',lw) rectangle('Position',[x,y,w,h],'FaceColor',color) rectangle('Position',[x,y,w,h],'EdgeColor',color)

其中,'Position'参数为矩形的位置和大小,以[x,y]为左下角坐标,w为宽度,h为高度;'LineWidth'参数为线条宽度;'FaceColor'参数为填充颜色;'EdgeColor'参数为边框颜色。

例如,绘制一个左下角坐标为(1,2),宽度为3,高度为4,填充颜色为蓝色,边框颜色为红色的矩形,可以使用以下代码:

rectangle('Position',[1,2,3,4],'FaceColor','b','EdgeColor','r')


原文地址: https://www.cveoy.top/t/topic/hb0n 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录