Solving and Plotting Initial Value Response using EXPM() function

1 次查看(过去 30 天)
How can I make matrix dimensions work when trying to solve and plot Initial Value Response to State Space model and using expm() function?
Code:
clear all
close all
clc
syms t
time = [0:0.01:10]
A = [0 1 ; -5 -2]
B = [0;1]
x_naut = [1;-1]
[eig_vector, eig_value] = eig(A)
v_inv = inv(eig_vector)
eAt = expm(A.*time)
x = expm(A).*x_naut
fplot(time,x)

回答(1 个)

Star Strider
Star Strider 2017-10-2
Try this:
time = [0:0.01:10];
A = [0 1 ; -5 -2];
B = [0;1];
x_naut = [1;-1];
for k1 = 1:numel(time)
eAt = expm(A.*time(k1));
x(:,k1) = [1 0; 0 1]*eAt*x_naut;
end
figure(1)
plot(time,x)
grid

类别

Help CenterFile Exchange 中查找有关 Symbolic Math Toolbox 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by