Solving and Plotting Initial Value Response using EXPM() function
1 view (last 30 days)
Show older comments
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)
0 Comments
Answers (1)
Star Strider
on 2 Oct 2017
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
0 Comments
See Also
Categories
Find more on Symbolic Math Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!