Matlab中极坐标的作图问题
发布网友
发布时间:2022-04-20 08:02
我来回答
共1个回答
热心网友
时间:2023-06-24 00:10
该线条端点转过的曲线应该是一个圆,参考以下代码(动态演示):
x1 = 2; y1 = 0;
T = linspace(0, 2*pi, 360);
x = zeros(size(T)) * NaN;
y = x;
clf
h1 = plot([0 x1],[0 y1], 'r', 'linewidth',2);
hold on
h2 = plot([0 x1],[0 y1], 'b', 'linewidth',2);
h3 = plot([x1 x1],[y1 y1], 'k:');
h4 = plot([x1 x1],[y1 y1], 'k:');
h5 = plot([0 x],[0 y], 'g', 'linewidth',2);
h6 = plot([0 x],[0 y], 'c--');
axis([-4 4 -4 4])
axis equal
for i = 1 : length(T)
x2 = 2 * cos(T(i));
y2 = 2 * sin(T(i));
x(i) = x1 + x2;
y(i) = y1 + y2;
set(h2, 'x', [0 x2], 'y', [0 y2]);
set(h3, 'x', [x1 x1+x2], 'y', [y1 y1+y2]);
set(h4, 'x', [x2 x1+x2], 'y', [y2 y1+y2]);
set(h5, 'x', [0 x(i)], 'y', [0 y(i)]);
set(h6, 'x', x, 'y', y);
drawnow
end