惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

罗磊的独立博客
Apple Machine Learning Research
Apple Machine Learning Research
The Cloudflare Blog
WordPress大学
WordPress大学
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - 叶小钗
博客园 - 聂微东
阮一峰的网络日志
阮一峰的网络日志
腾讯CDC
博客园 - 三生石上(FineUI控件)
V
V2EX
有赞技术团队
有赞技术团队
V
Visual Studio Blog
小众软件
小众软件
Jina AI
Jina AI
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - Franky
量子位
T
Tailwind CSS Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
P
Palo Alto Networks Blog
Cisco Talos Blog
Cisco Talos Blog
I
Intezer
Project Zero
Project Zero
A
Arctic Wolf
P
Privacy International News Feed
V
Vulnerabilities – Threatpost
L
Lohrmann on Cybersecurity
S
Securelist
C
Cybersecurity and Infrastructure Security Agency CISA
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Tor Project blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
S
Security @ Cisco Blogs
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Google DeepMind News
Google DeepMind News
N
News and Events Feed by Topic
TaoSecurity Blog
TaoSecurity Blog
L
LINUX DO - 热门话题
G
GRAHAM CLULEY
Help Net Security
Help Net Security
N
News | PayPal Newsroom
W
WeLiveSecurity
G
Google Developers Blog
Microsoft Security Blog
Microsoft Security Blog
Engineering at Meta
Engineering at Meta
MongoDB | Blog
MongoDB | Blog
C
Check Point Blog

博客园 - 遗忘海岸

简协运动模拟 电磁场中的运动轨迹模拟 圆周运动模拟 C# 队列的一些并发模拟 devexpress gridview master,detail视图 focuseRowHandle 同步选中 C# Tcp Server端实现,使用TcpListener 深信服务超融合管理Api调用 GDI+画工作流图的一些总结 绘制贝塞而曲线 GDI+画直线带箭头 devexpress schedulerControl Gantt View 使用 逻辑回归损失函数求导 matplotlim柱状图 匀加速运动模拟python,(matplotlib) C# 实现排列 python 类鸟群Boids C#动态编译 正太分布数据排序后分段数据的方差与标准差 Android 的一个通用列表单选AlertDialog封装
带阻力的平抛运动
遗忘海岸 · 2025-12-17 · via 博客园 - 遗忘海岸

%% 带阻力(f=kv)的平抛运动模拟
close
clc
clear
hold on
grid on
axis equal;


%% 参数设置
m = 1;           % 质量 (kg)
k = 0.98;          % 阻力系数 (kg/s)
g = 9.8;           % 重力加速度 (m/s^2)
v0 = 10;           % 初始速度 (m/s)
h0 = 20;          % 初始高度 (m)



% 初始位置
x0 = 0;
y0 = h0;

%% 时间设置
dt = 0.0001;         % 时间步长 (s)
t_max = 15;        % 最大模拟时间 (s)
t = 0:dt:t_max;    % 时间向量
N = length(t);

%% 初始化数组
x = [];
y = [];
vy = -v0; %垂直方向做匀速运动,整个过程速度不变
v_tilt = [];
a_tilt = []; %倾斜方向


% 设置初始条件
x(1) = x0;
y(1) = y0;

v_tilt(1) =sqrt(2) * v0 ;

%% 数值求解(欧拉法)
s_theta=atan(-vy/v0);
for i = 1:N-1
    
    
    % 计算加速度(考虑阻力)
    a_tilt(i)=-(k/m) * v_tilt(i);
    
    % 更新速度和位置
    v_tilt(i+1) = v_tilt(i) + a_tilt(i) * dt;
    s_tilt=v_tilt(i)*dt;%倾斜方向运行的距离,需要分析成水平与垂直方向

    x(i+1) = x(i) + s_tilt * sqrt(1/2);
    y(i+1) = y(i) + vy*dt + s_tilt * sqrt(1/2);


   if length(x) >=2
    %45度退出
    x_end=x(end)- x(end-1);
    y_end=y(end)- y(end-1);
    d=abs(atand (y_end/x_end));
    if d >=45
        fprintf('到达45:\n');
         v_a=[0,vy];
        v_b=[v_tilt(i) * cos(s_theta),v_tilt(i) * sin(s_theta)];
        v_c=v_a+v_b;
        fprintf('当前速度:%.2f\n',norm(v_c));
        % fprintf('当前速度:%.2f\n',sqrt(vy^2 +v_tilt(i)^2 -
        % 2*vy*v_tilt(i)*cos(3*pi/4) )); %有问题不能按余弦定理计算
        break;
    end
   end

end

plot(x, y, 'b-', 'LineWidth', 1);
fprintf("计算速度:%.2f\n",sqrt(1/2)*v0);


%% 无阻力
x_n=[x0];
y_n=[y0];
vx_n=v0;
vy_n=0;

i=0;
while y_n(end)>=0
 i=i+1;
 vx_n=v0;
 vy_n=vy_n - g*dt;
 x_n(i+1)=x_n(i)+vx_n*dt;
 y_n(i+1)=y_n(i)+vy_n*dt;

 if(y_n(end)<= y(end))
    break;
 end
end
plot(x_n, y_n, 'r-', 'LineWidth', 1);

View Code

以上是采用配速法后的模拟,注意不是特殊角时需要使用正弦定理 a/sin(a) = b/sin(b) =c/sin(c) 来求解

%% 带阻力(f=kv)的平抛运动模拟
close
clc
clear
hold on
grid on
axis equal;


%% 参数设置
m = 1;           % 质量 (kg)
k = 0.98;          % 阻力系数 (kg/s)
g = 9.8;           % 重力加速度 (m/s^2)
v0 = 10;           % 初始速度 (m/s)
theta = 0;         % 平抛,角度为0度
h0 = 20;          % 初始高度 (m)

% 将角度转换为弧度
theta_rad = deg2rad(theta);

% 初始速度分量
vx0 = v0 * cos(theta_rad);
vy0 = v0 * sin(theta_rad);

% 初始位置
x0 = 0;
y0 = h0;

%% 时间设置
dt = 0.0001;         % 时间步长 (s)
t_max = 15;        % 最大模拟时间 (s)
t = 0:dt:t_max;    % 时间向量
N = length(t);

%% 初始化数组
x = [];
y = [];
vx = [];
vy = [];
ax = [];
ay = [];

% 设置初始条件
x(1) = x0;
y(1) = y0;
vx(1) = vx0;
vy(1) = vy0;

%% 数值求解(欧拉法)
for i = 1:N-1

    
    % 计算加速度(考虑阻力)
    ax(i) = -(k/m) * vx(i);           % x方向:只有阻力
    ay(i) = -g - (k/m) * vy(i);       % y方向:重力 + 阻力,vy内容是负的,所以这里取负号
    
    % 更新速度和位置
    vx(i+1) = vx(i) + ax(i) * dt;
    vy(i+1) = vy(i) + ay(i) * dt;
    x(i+1) = x(i) + vx(i) * dt;
    y(i+1) = y(i) + vy(i) * dt;


   if length(x) >=2
    %45度退出
    x_end=x(end)- x(end-1);
    y_end=y(end)- y(end-1);
    d=abs(atand (y_end/x_end));
    if d >=45
        fprintf('到达45:\n');
        fprintf('当前速度:%.2f\n',sqrt(vx(i)^2 +vy(i)^2));
         break;
    end
   end

end

plot(x, y, 'b-', 'LineWidth', 1);
fprintf("计算速度:%.2f\n",sqrt(1/2)*v0);


%% 无阻力
x_n=[x0];
y_n=[y0];
vx_n=v0;
vy_n=0;

i=0;
while y_n(end)>=0
 i=i+1;
 vx_n=v0;
 vy_n=vy_n - g*dt;
 x_n(i+1)=x_n(i)+vx_n*dt;
 y_n(i+1)=y_n(i)+vy_n*dt;

 if(y_n(end)<= y(end))
    break;
 end
end
plot(x_n, y_n, 'r-', 'LineWidth', 1);

View Code

以上是按正交分解的模拟,两个结果一直

zlpp