function [t,r] = solve_ode(wn, c, e, w, tspan, r0) % wn - 自然频率 % c - 阻尼系数 % e - 外界扰动因子 % w - 外界扰动频率 % tspan - 时间区间 % r0 - 初值条件

% 定义ODE方程 f = @(t,r) [r(2); (-wnwnr(1)-2wncr(2)+ewwcos(w*t))];

% 解ODE方程 [t,r] = ode45(f, tspan, r0);

% 绘制图像 figure; plot(t, r(:,1)); xlabel('Time'); ylabel('Angle'); title('Relationship between angle and time'); end

用matlab编写f = tr r2; -wnwnr1-2wncr2+ewwcoswt转角与时间的关系

原文地址: https://www.cveoy.top/t/topic/d9ht 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录