Matlab中极坐标的作图问题
来源:学生作业帮 编辑:神马作文网作业帮 分类:综合作业 时间:2024/11/18 10:11:39
Matlab中极坐标的作图问题
极坐标中,从极点开始,角度为0,长度为2的一条线固定不动;
另外一条从极点开始,长度为2的线从0度开始旋转,旋转360度,
转动到每个角度时,根据平行四边形法则,他们都会有一条斜线(或加和与相减的线),这条线转动的区域的面积该如何用图表示出来?
如果可能,麻烦给出具体的代码.
极坐标中,从极点开始,角度为0,长度为2的一条线固定不动;
另外一条从极点开始,长度为2的线从0度开始旋转,旋转360度,
转动到每个角度时,根据平行四边形法则,他们都会有一条斜线(或加和与相减的线),这条线转动的区域的面积该如何用图表示出来?
如果可能,麻烦给出具体的代码.
该线条端点转过的曲线应该是一个圆,参考以下代码(动态演示):
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
再问: 麻烦问一下,如果我想在极坐标中绘制这样的图形,应该怎么做呢
再答: x1 = 2; y1 = 0;
T = linspace(0, 2*pi, 360);
x = zeros(size(T)) * NaN;
y = x;
clf
h5 = polar([0 0],[0 4], 'g');
hold on
h1 = plot([0 x1],[0 y1], 'r', 'linewidth',2);
h2 = plot([0 x1],[0 y1], 'b', 'linewidth',2);
h3 = plot([x1 x1],[y1 y1], 'k:');
h4 = plot([x1 x1],[y1 y1], 'k:');
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
再问: 最后再麻烦一下您,如果我想让不动的那条线以一定的速度(比如说2)也转动起来,其它条件也不更改,应该如何调整参数呢?
再问: 最后再麻烦一下您,如果我想让不动的那条线以一定的速度(比如说2)也转动起来,其它条件也不更改,应该如何调整参数呢?
再答: 你说的【速度为2】是什么概念?线条转动速度的绝对值没有意义,是不是说按照比另一条快2倍的速度转动?x1 = 2; y1 = 0;
T = linspace(0, 2*pi, 360);
x = zeros(size(T)) * NaN;
y = x;
clf
h5 = polar([0 0],[0 4], 'g');
% set(h5, 'linewidth',2,'erasemode','none')
hold on
h1 = plot([0 x1],[0 y1], 'r', 'linewidth',2);
h2 = plot([0 x1],[0 y1], 'b', 'linewidth',2);
h3 = plot([x1 x1],[y1 y1], 'k:');
h4 = plot([x1 x1],[y1 y1], 'k:');
h6 = plot([0 x],[0 y], 'c--');
axis([-4 4 -4 4])
axis equal
for i = 1 : length(T)
x1 = 2 * cos(2*T(i));
y1 = 2 * sin(2*T(i));
x2 = 2 * cos(T(i));
y2 = 2 * sin(T(i));
x(i) = x1 + x2;
y(i) = y1 + y2;
set(h1, 'x', [0 x1], 'y', [0 y1]);
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
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
再问: 麻烦问一下,如果我想在极坐标中绘制这样的图形,应该怎么做呢
再答: x1 = 2; y1 = 0;
T = linspace(0, 2*pi, 360);
x = zeros(size(T)) * NaN;
y = x;
clf
h5 = polar([0 0],[0 4], 'g');
hold on
h1 = plot([0 x1],[0 y1], 'r', 'linewidth',2);
h2 = plot([0 x1],[0 y1], 'b', 'linewidth',2);
h3 = plot([x1 x1],[y1 y1], 'k:');
h4 = plot([x1 x1],[y1 y1], 'k:');
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
再问: 最后再麻烦一下您,如果我想让不动的那条线以一定的速度(比如说2)也转动起来,其它条件也不更改,应该如何调整参数呢?
再问: 最后再麻烦一下您,如果我想让不动的那条线以一定的速度(比如说2)也转动起来,其它条件也不更改,应该如何调整参数呢?
再答: 你说的【速度为2】是什么概念?线条转动速度的绝对值没有意义,是不是说按照比另一条快2倍的速度转动?x1 = 2; y1 = 0;
T = linspace(0, 2*pi, 360);
x = zeros(size(T)) * NaN;
y = x;
clf
h5 = polar([0 0],[0 4], 'g');
% set(h5, 'linewidth',2,'erasemode','none')
hold on
h1 = plot([0 x1],[0 y1], 'r', 'linewidth',2);
h2 = plot([0 x1],[0 y1], 'b', 'linewidth',2);
h3 = plot([x1 x1],[y1 y1], 'k:');
h4 = plot([x1 x1],[y1 y1], 'k:');
h6 = plot([0 x],[0 y], 'c--');
axis([-4 4 -4 4])
axis equal
for i = 1 : length(T)
x1 = 2 * cos(2*T(i));
y1 = 2 * sin(2*T(i));
x2 = 2 * cos(T(i));
y2 = 2 * sin(T(i));
x(i) = x1 + x2;
y(i) = y1 + y2;
set(h1, 'x', [0 x1], 'y', [0 y1]);
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