Solving and Plotting Initial Value Response using EXPM() function

1 visualización (últimos 30 días)
Nick Alden
Nick Alden el 2 de Oct. de 2017
Respondida: Star Strider el 2 de Oct. de 2017
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)

Respuestas (1)

Star Strider
Star Strider el 2 de Oct. de 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

Categorías

Más información sobre Symbolic Math Toolbox en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by