Applying single input and single output to mimo system
조회 수: 24 (최근 30일)
이전 댓글 표시
I have a MIMO system and one of the questions presented in my assignment is to plot the open-loop output displacement for unit step input u2(t) and output y3(t), assuming zero initial state. In order to apply this, I zero out my u1&u3 inputs, and for my y3(t), I edit my C matrix to only have 1 in the third column bottom row.
The way I have my code setup is that I have a subplot that produces 3 graphs and a single plot that produces all 3 graphs on 1 plot. When I run my code I expect to see the subplot and the single plot to have the same plots, however this is not the case, am hoping someone can point out where my error is. Be it the way I have set up my plots or the way I set up my matrices.
% Mass values
m1 = 1;
m2 = 2;
m3 = 3;
% Spring Coefficients
k1 = 10;
k2 = 20;
k3 = 30;
k4 = 40;
% Damping Coefficients
c1 = 0.4;
c2 = 0.8;
c3 = 1.2;
c4 = 1.6;
% A, B, C and D matrix generated from chapter 1.
A = [0 0 0 1 0 0;
0 0 0 0 1 0;
0 0 0 0 0 1;
((-1)*((k1+k2)/m1)) (k2/m1) 0 ((-1)*((c1+c2)/m1)) (c2/m1) 0;
(k2/m2) ((-1)*((k2+k3)/m2)) (k3/m3) (c2/m2) ((-1)*((c2+c3)/m2)) (c3/m2);
0 (k3/m3) ((-1)*((k3+k4)/m3)) 0 (c3/m3) ((-1)*((c3+c4)/m3))];
B = [0 0 0;
0 0 0;
0 0 0;
(1/m1) 0 0;
0 (1/m2) 0;
0 0 (1/m3)];
C = [0 0 0 0 0 0;
0 0 0 0 0 0;
0 0 1 0 0 0];
D = [0 0 0;
0 0 0;
0 0 0];
sys_1 = ss(A,B,C,D);
t = [0:.01:40]; % Define time values
% Since this section asks for 1 unit step input u2(t), u1(t)& u3(t) is
% zeroed out.
u1 = [zeros(size(t))];
u2 = [ones(size(t))];
u3 = [zeros(size(t))];
u = [u1;u2;u3];
x0 = [0;0;0;0;0;0]; % Assume zero initial state
[Y,t,X0]=lsim(sys_1,u,t,x0);
% Keep this to compare with subplot. This plot produces all 3 plots on 1
% graph.
plot(t,Y)
grid;
X0(101,:);
figure();
subplot(3,1,1)
plot(t,X0(:,1));
grid;
ylabel('Amplitude');
subplot(3,1,2)
plot(t,X0(:,2));
grid;
ylabel('Amplitude');
subplot(3,1,3)
plot(t,X0(:,3));
grid;
ylabel('Amplitude');
xlabel('time (sec)');
댓글 수: 0
채택된 답변
Paul
2021년 11월 15일
The definition of sys1 has three outputs. However, the first two rows of C are zero, so outputs y1 and y2 will be zero. The third output y3 = x3.
The subplots are plotting the first three states (of six), x1, x2, and x3. So the only subplot that will match an output is the third one, on which you can overlay y3 and x3. Also, for a step response the step() command will work just fine. And since you only care about y3 due to u2, you can specify to use only sys1(3,2).
% Mass values
m1 = 1;
m2 = 2;
m3 = 3;
% Spring Coefficients
k1 = 10;
k2 = 20;
k3 = 30;
k4 = 40;
% Damping Coefficients
c1 = 0.4;
c2 = 0.8;
c3 = 1.2;
c4 = 1.6;
% A, B, C and D matrix generated from chapter 1.
A = [0 0 0 1 0 0;
0 0 0 0 1 0;
0 0 0 0 0 1;
((-1)*((k1+k2)/m1)) (k2/m1) 0 ((-1)*((c1+c2)/m1)) (c2/m1) 0;
(k2/m2) ((-1)*((k2+k3)/m2)) (k3/m3) (c2/m2) ((-1)*((c2+c3)/m2)) (c3/m2);
0 (k3/m3) ((-1)*((k3+k4)/m3)) 0 (c3/m3) ((-1)*((c3+c4)/m3))];
B = [0 0 0;
0 0 0;
0 0 0;
(1/m1) 0 0;
0 (1/m2) 0;
0 0 (1/m3)];
C = [0 0 0 0 0 0;
0 0 0 0 0 0;
0 0 1 0 0 0];
D = [0 0 0;
0 0 0;
0 0 0];
sys_1 = ss(A,B,C,D);
t = [0:.01:40]; % Define time values
% Since this section asks for 1 unit step input u2(t), u1(t)& u3(t) is
% zeroed out.
% u1 = [zeros(size(t))];
% u2 = [ones(size(t))];
% u3 = [zeros(size(t))];
% u = [u1;u2;u3];
% x0 = [0;0;0;0;0;0]; % Assume zero initial state
% [Y,t,X0]=lsim(sys_1,u,t,x0); % would be more clear to call the output X,
% not X0'
[Y3,t,X] = step(sys_1(3,2)); % step response from u2 to y3. Y will only have one column
% Keep this to compare with subplot. This plot produces all 3 plots on 1
% graph.
plot(t,Y3)
grid;
ylabel('Y3')
X(101,:);
figure();
subplot(3,1,1)
plot(t,X(:,1));
grid;
ylabel('Amplitude X1');
subplot(3,1,2)
plot(t,X(:,2));
grid;
ylabel('Amplitude X2');
subplot(3,1,3)
plot(t,X(:,3),t(1:10:end),Y3(1:10:end),'o'); %overlay with Y
grid;
ylabel('Amplitude');
legend('x3','y3')
xlabel('time (sec)');
댓글 수: 2
Paul
2021년 11월 16일
When I said "would be more clear to call the output X, not X0" I was referring to the third output of the function lsim() or step(), not the output of the system sys_1. In this command
[Y,t,X0] = lsim(sys_1,u,t,x0)
the lsim() output X0 on the left hand side is the state vector of the system sys_1 in response to input u with initial conditions x0. Take a look at
doc lsim
doc step
The state vector of a linear system is commonly called X and the initial state X0. In this case, the function output X0 is uppercase and the function input x0 is lowercase, so they are different Matlab variables. I was just suggesting to make the third function output X, to follow convention and avoid confusion between X0 and x0.
The A matrix of the sys_1 is 6x6, so the system has six state variables. From the form of the equations it looks like the the first three states are positions of three connected masses and the second three states are their velocities of the masses. I'm just guessing, but you formed the equations so you should know what they represent. When you plot the first three states, which are columns 1-3 of X0 (using the command shown above) you're plotting the mass positions. Columns 4-6 would be the mass velocities (assuming my guess is correct).
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Time and Frequency Domain Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!