Matlab模拟旋转圆的动画
Matlab模拟旋转圆的动画
TT_Matlab
博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,完整matlab代码或者程序定制加qq1575304183。
1 简介
Matlab模拟旋转圆的动画
2 完整代码
%% Circle Illusion - Moving dots to rotating circle
% Animation of a rotating circle that emerges from a set of dots moving
% harmonically in straight lines with different orientations.
%
%%
clear ;
close
all ; clc
%% Parameters
% Video
tf =
30
; % Final
time
[
s
]
fR =
30
; % Frame rate [fps]
dt =
1
/fR; % Time resolution [
s
]
t = linspace(
0
,tf,tf*fR); % Time [
s
]
% Dots
T =
10
; % Oscillation period [
s
]
f =
1
/T; % Oscillation frequency [Hz]
A =
1
; % Amplitude [
m
]
N =
8
; % Number of dots
ph = pi/N; % Phase [rad]
th = pi/N; % Orientation [rad]
%% Defining motion
% Preallocating
px = zeros(
length
(t),N);
py = zeros(
length
(t),N);
% Position matrices
for
i =
1
:N
px(:,i) = A*
sin
(
2
*pi*f*t + i*ph) *
cos
(i*th);
py(:,i) = A*
sin
(
2
*pi*f*t + i*ph) *
sin
(i*th);
end
%% Animation
figure
% set(gcf,
’Position’
,[
50
50
1280
720
]) % YouTube:
720
p
% set(gcf,
’Position’
,[
50
50
854
480
]) % YouTube:
480
p
set(gcf,
’Position’
,[
50
50
640
640
]) % Social
hold on ; grid on ; box on ; axis equal
set(gca,
’xlim’
,[-
1.1
1.1
],
’ylim’
,[-
1.1
1.1
])
set(gca,
’XTick’
,[],
’YTick’
,[])
set(gca,
’FontName’
,
’Verdana’
,
’FontSize’
,
22
)
title(
’Circle Illusion’
)
% Create
and
open
video writer object
v = VideoWriter(
’circle_illusion.mp4’
,
’MPEG-4’
);
v.Quality =
100
;
v.FrameRate = fR;
open
(v);
% Generating frames
for
i=
1
:
length
(t)
cla
for
j=
1
:N
plot([-A*
cos
(j*th) A*
cos
(j*th)],[-A*
sin
(j*th) A*
sin
(j*th)],
’:’
,
’Color’
,[
100
100
100
]/
255
,
’LineWidth’
,
1.5
)
end
plot(px(i,:),py(i,:),
’ro’
,
’MarkerFaceColor’
,
’r’
,
’MarkerEdgeColor’
,
’k’
,
’MarkerSize’
,
15
)
frame = getframe(gcf);
writeVideo(v,frame);
end
close
(v);
3 仿真结果
4 参考文献
博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,相关matlab代码问题可私信交流。
部分理论引用网络文献,若有侵权联系博主删除。
-
2023年血糖新标准公布,不是3.9-6.1,快来看看你的血糖正常吗? 2023-02-07
-
2023年各省最新电价一览!8省中午执行谷段电价! 2023-01-03
-
GB 55009-2021《燃气工程项目规范》(含条文说明),2022年1月1日起实施 2021-11-07
-
PPT导出高分辨率图片的四种方法 2022-09-22
-
2023年最新!国家电网27家省级电力公司负责人大盘点 2023-03-14
-
全国消防救援总队主官及简历(2023.2) 2023-02-10
-
盘点 l 中国石油大庆油田现任领导班子 2023-02-28
-
我们的前辈!历届全国工程勘察设计大师完整名单! 2022-11-18
-
关于某送变电公司“4·22”人身死亡事故的快报 2022-04-26
