填充图动画(极性功能)

发布于 2025-01-23 14:18:37 字数 498 浏览 0 评论 0原文

我在作业中显示了一组视频。该动画是如何创建的?我正在尝试创建类似的东西。以下是我的尝试;它只是绘图线,因为我相信它没有填充正确的输入。指导将不胜感激

clear;close all;

th = 0:0.1:pi*2
r = cos(2*th) .* sin(2*th);
x = r .* cos(th);
y = r .* sin(th);
plot(x,y);
hold on

for th = 0:0.1:pi*2
  x0 = [r .* cos(th)];
  y0 = [r .* sin(th)];
  fill(x0,y0,'b');
  pause (0.5);
end
hold off

enter image description here

I have a set of videos shown in an assignment. How is this animation created? I am trying to create something similar. Below is my attempt; it is only drawing lines because I believe it is not filling in the correct inputs. Guidance would be much appreciated

clear;close all;

th = 0:0.1:pi*2
r = cos(2*th) .* sin(2*th);
x = r .* cos(th);
y = r .* sin(th);
plot(x,y);
hold on

for th = 0:0.1:pi*2
  x0 = [r .* cos(th)];
  y0 = [r .* sin(th)];
  fill(x0,y0,'b');
  pause (0.5);
end
hold off

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

停顿的约定 2025-01-30 14:18:37

我设法用Polarplot(Th,Radius)在极性坐标中绘制该功能,我无法填充黄色,也不会使图动画,对不起。

clear;close all;

th = linspace(0, 2*pi, 1000);

r = cos(2 .* th) .* sin(2 .* th);

polarplot(th,r)

I managed to draw the function in polar coordinates with polarplot(th, radius), I could not fill with yellow color and neither animate the graph, I'm sorry.

clear;close all;

th = linspace(0, 2*pi, 1000);

r = cos(2 .* th) .* sin(2 .* th);

polarplot(th,r)
梨涡少年 2025-01-30 14:18:37

可以通过填写列表来绘制类似的动画。将clf放在前面的循环中是可选的。

以下代码动画了一朵小花的绘图过程。通过更改轴,花将看起来比例更大或更小。

X = 0:0.01:pi*2;
r = cos(2*X).*sin(2*X);

x=r.*(cos(X));
y=r.*(sin(X));

x_1 = []; y_1 = [];

for i=1:629                    %629 is the size of x and of y
    x_1 = [x(i), x_1];
    y_1 = [y(i), y_1];
    
    fill(x_1,y_1,'b'); hold on;
    axis([-2 2 -2 2]); hold on;
    pause(0.01);
end

A similar animation can be drawn by filling from lists. Putting clf in the for-loop is optional.

This following code animates the drawing process of a small flower. The flower will look proportionally bigger or smaller by changing the axis.

X = 0:0.01:pi*2;
r = cos(2*X).*sin(2*X);

x=r.*(cos(X));
y=r.*(sin(X));

x_1 = []; y_1 = [];

for i=1:629                    %629 is the size of x and of y
    x_1 = [x(i), x_1];
    y_1 = [y(i), y_1];
    
    fill(x_1,y_1,'b'); hold on;
    axis([-2 2 -2 2]); hold on;
    pause(0.01);
end
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文