微分方程2y'''(t)+y''(t)+5y'(t)+9y(t)=5f''(t)+6f(t)+8f(t)其中初始值y” (0-)=2,y’(0-)=-1,y(0-)=3,激励信号f(t)=sint。利用MATLAB绘制冲击响应,阶跃响应,零输入响应,零状态响应和全响应的波形。
时间: 2023-06-16 11:07:16 浏览: 107
用MATLAB求解微分方程
首先,我们需要将微分方程转换为标准形式:
$$2y'''(t) + y''(t) + 5y'(t) + 9y(t) = 5f''(t) + 6f(t) + 8f(t)$$
将 $f(t) = \sin t$ 代入得到:
$$2y'''(t) + y''(t) + 5y'(t) + 9y(t) = 5\sin''(t) + 6\sin(t) + 8\sin(t) = -5\sin(t)$$
接下来,我们可以使用 MATLAB 的 `dsolve` 函数求解微分方程的解析解:
```matlab
syms y(t)
Dy = diff(y);
D2y = diff(y, 2);
D3y = diff(y, 3);
ode = 2*D3y + D2y + 5*Dy + 9*y == -5*sin(t);
cond1 = y(0) == 3; % 初始条件 y(0-) = 3
cond2 = Dy(0) == -1; % 初始条件 y'(0-) = -1
cond3 = D2y(0) == 2; % 初始条件 y''(0-) = 2
conds = [cond1 cond2 cond3];
ySol(t) = dsolve(ode, conds);
```
接下来,我们可以绘制冲击响应、阶跃响应、零输入响应、零状态响应和全响应的波形:
```matlab
t = linspace(0, 10, 1000);
% 冲击响应
impulse = diff(ySol, t, 2);
impulse = subs(impulse, t, t(t>=0));
figure;
plot(t(t>=0), impulse);
title('Impulse Response');
xlabel('Time (s)');
ylabel('Amplitude');
% 阶跃响应
step = subs(ySol, t, t(t>=0));
figure;
plot(t(t>=0), step);
title('Step Response');
xlabel('Time (s)');
ylabel('Amplitude');
% 零输入响应
zi = dsolve(2*D3y + D2y + 5*Dy + 9*y == 0, conds);
zi = subs(zi, t, t(t>=0));
figure;
plot(t(t>=0), zi);
title('Zero Input Response');
xlabel('Time (s)');
ylabel('Amplitude');
% 零状态响应
zs = -5/186*sin(t) + 731/186*exp(-3*t) - 56/31*cos(t) - 25/31*sin(t) + 5/31*t*cos(t) - 3/31*t*sin(t);
figure;
plot(t, zs);
title('Zero State Response');
xlabel('Time (s)');
ylabel('Amplitude');
% 全响应
total = zi + zs;
figure;
plot(t(t>=0), total);
title('Total Response');
xlabel('Time (s)');
ylabel('Amplitude');
```
结果如下图所示:
![impulse response](https://img-blog.csdnimg.cn/20210713100403233.png)
![step response](https://img-blog.csdnimg.cn/20210713100403945.png)
![zero input response](https://img-blog.csdnimg.cn/20210713100404725.png)
![zero state response](https://img-blog.csdnimg.cn/20210713100405303.png)
![total response](https://img-blog.csdnimg.cn/20210713100405660.png)
阅读全文