Discrete state space find and plot

조회 수: 6 (최근 30일)
Jack Reacher
Jack Reacher 2016년 12월 3일
편집: bio lim 2016년 12월 3일
A = [0 1 0 0 0; -0.4 -1.3 0 0 0; 0 0 2 0 0; 0 0 0 0 -0.4; 0 0 0 1 -1.3];
B = [0; 1; 0; 0; 0];
C = [0 0 0 0 1];
x0 = transpose([0 0 0 0 0]); % initial condition
u = 1(k) % unit step
Find and plot:
x(k + 1) = A*x(k) + B*u(k)
How do I do this without using ss() and lsim(), and instead by using a for loop for 100 time units?
Thanks

채택된 답변

bio lim
bio lim 2016년 12월 3일
편집: bio lim 2016년 12월 3일
Well, the nice thing about discrete time system is you can solve the discrete time equation with a loop.
clc;
clear all;
close all;
A = [0 1 0 0 0; -0.4 -1.3 0 0 0; 0 0 2 0 0; 0 0 0 0 -0.4; 0 0 0 1 -1.3];
B = [0; 1; 0; 0; 0];
C = [0 0 0 0 1];
x0 = transpose([0 0 0 0 0]); % initial condition
u = 1; % unit step
x(:,1) = A*x0 + B.*u;
% x(k + 1) = A*x(k) + B*u(k)
for k = 2:100
x(:,k) = A*x(:,k-1) + B*u;
end
  댓글 수: 3
Jack Reacher
Jack Reacher 2016년 12월 3일
This is what I did to plot the 5 states. But, I'm not sure I got the right plots. -Thanks
clc;
clear;
close;
A = [0 1 0 0 0; -0.4 -1.3 0 0 0; 0 0 2 0 0; 0 0 0 0 -0.4; 0 0 0 1 -1.3];
B = [0; 1; 0; 0; 0];
C = [0 0 0 0 1];
x0 = transpose([0 0 0 0 0]);
u = 1;
x(:, 1) = A*x0 + B*u;
for k = 2: 100
x(:, k) = A*x(:, k - 1) + B*u;
end
t = 1: 100;
subplot(2, 3, 1);
plot(t, x(1, :))
subplot(2, 3, 2);
plot(t, x(2, :))
subplot(2, 3, 3);
plot(t, x(3, :))
subplot(2, 3, 4);
plot(t, x(4, :))
subplot(2, 3, 5);
plot(t, x(5, :))
bio lim
bio lim 2016년 12월 3일
편집: bio lim 2016년 12월 3일
You are plotting them right. I think, the last three states are not excited enough either due to initial condition, or your system dynamic configuration. Try changing the initial conditions, and see how it changes.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Stability Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by