1 Star 0 Fork 0

ACertainUser/我的赛博大物实验

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
pendulum.m 518 Bytes
一键复制 编辑 原始数据 按行查看 历史
% 这个脚本演示了一个简单的摆锤
% CC-BY 4
clc
clear
dt = 0.01;
n = 2000;
theta = zeros(n,1);
t = zeros(n,1);
g=10;
r=1;
theta(1) = 0;
theta(2) = 0;
figure()
k = 1;
for i=2:n-1
t(i+1) = t(i)+dt;
theta(i+1) = 2*theta(i) - theta(i-1) + g/r*cosd(theta(i))*dt*dt;
if mod(k,10) == 1
clf
hold on
axis equal
axis([-2 2 -2 2])
scatter(0,0);
x = r*cosd(theta(i));
y = -r*sind(theta(i));
scatter(x,y);
line([0 x],[0 y])
drawnow
pause(0.01)
end
k++;
end
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Matlab
1
https://gitee.com/acertainuser/my---matlab-script.git
git@gitee.com:acertainuser/my---matlab-script.git
acertainuser
my---matlab-script
我的赛博大物实验
master

搜索帮助