matlab - 如何在 MATLAB/OCTAVE 中创建一个带孔的矩形?
问题描述
我想在 MATLAB 或 OCTAVE 中准确地绘制/绘制这个形状。当然,我确实知道如何绘制,以及如何使用绘图、线条或矩形函数创建矩形。但我还没有设法在矩形的顶部添加这个“洞”。我想,它是一个半径为 0.5 和中心点 (1.5|2) 的(半)圆。在 OCTAVE 中,有一个drawCircleArc
功能,但我不想只画那个东西,还想有必要的坐标来定义整个形状以便进一步操作。
解决方案
这是一种方式(matlab/octave 兼容):
% Specify all polygon points, excluding the semi-circle outline
X = [1, 0, 0, 3, 3, 2];
Y = [2, 2, 0, 0, 2, 2];
% Add semi-circle outline to array of polygon points
t = 0 : -0.01 : -pi;
X = [X, 1.5 + 0.5 * cos(t)];
Y = [Y, 2 + 0.5 * sin(t)];
% Use fill to plot the filled polygon, with desired settings
fill( X, Y, [0.8, 0.8, 0.8], 'linewidth', 1.5 );
axis( [-2, 4, -2, 4] ); axis equal;
推荐阅读
- python - 在 Python3 中覆盖 __repr__()?
- python - 为什么我在机器学习模型中为相同的输入得到不同的输出
- node.js - 如何在 expressjs 中构建 HTTP 错误处理程序?
- vue.js - VueJS 意外运行了一个函数
- r - 在 R 中将 +1 添加到季度(日期)
- asp.net - 快速响应但继续处理的 IIS 请求
- arrays - 根据另一个工作表中的一列数据的结果创建一个表并消除空值
- php - 如何在使用 TCPDF 的语句中的值发生更改时添加新页面
- python-2.7 - 使用 While 循环或 For 循环
- powershell - 如何从 Remove-Item 捕获错误并发出警告?