MATLAB求解微分方程零输入、零状态及完全响应
首先,我们需要将微分方程转化为状态空间形式。
令x1(t) = y(t),x2(t) = y'(t),x3(t) = x(t),将微分方程转化为矩阵形式:
x1'(t) = x2(t) x2'(t) = -2x1(t) - 3x2(t) + x3'(t) + 3x3(t) x3(t) = e^(-3t)
然后,我们可以使用MATLAB的ode45函数来求解状态方程的零输入响应、零状态响应和完全响应。
以下是MATLAB代码:
function dxdt = state_eq(t, x)
dxdt = zeros(3, 1);
dxdt(1) = x(2);
dxdt(2) = -2*x(1) - 3*x(2) + x(4) + 3*x(3);
dxdt(3) = exp(-3*t);
dxdt(4) = 0;
end
% 时间范围
tspan = [0 10];
% 初始条件
x0 = [1; 2; 0; 0];
% 求解状态方程
[t, x] = ode45(@state_eq, tspan, x0);
% 提取输出
y = x(:, 1);
dy = x(:, 2);
x = x(:, 3);
% 零输入响应
zi_response = y;
% 零状态响应
zs_response = exp(-3*t);
% 完全响应
total_response = zi_response + zs_response;
% 绘制图像
plot(t, zi_response, 'r', t, zs_response, 'g', t, total_response, 'b');
xlabel('时间');
ylabel('响应');
legend('零输入响应', '零状态响应', '完全响应');
运行该代码,我们可以得到零输入响应、零状态响应和完全响应的图像。
原文地址: https://www.cveoy.top/t/topic/pkMp 著作权归作者所有。请勿转载和采集!