How to apply a step input to only ONE of the multi-inputs in a MIMO state space model?

Hi,
I have a state space model of an aircraft at a specific flight condition as follows:
A = [ -12 -4 1 -1;...
1 -5 4 2;...
0 0 5 -2;...
5 5 2 0];
%inputs: u1 u2 u3 u4 u5 u6 u7
B = [10 2 -11 17 2 7 34;...
10 0 5 0 -6 1 9;...
-10 0 2 -10 7 1 5;...
0 0 0 0 0 0 0];
C = [1 0 0 0;...
0 1 0 0;...
0 0 1 0;...
0 0 0 1;...
0 0 0 0;...
.1 0 .1 0;...
0 .1 .1 .1;...
0 0 .1 .1;...
0 0 0 0];
D = [0 0 0 0 0 0 0;...
0 0 0 0 0 0 0;...
0 0 0 0 0 0 0;...
0 0 0 0 0 0 0;...
0 0 0 0 0 0 0;...
0 0 0 0 0 0 0;...
0 0 .1 0 0 0 0;...
0 .1 0 0 0 .1 0;...
0 .1 0 0 .1 0 0];
%state space
sys = ss(A,B,C,D); %ss system
[y1,t,x1] = step(sys); %get sim time only
t=t'; %sim time
%step input applied only to elevator
u = [zeros(size(t)); zeros(size(t)); ones(size(t)); zeros(size(t));...
zeros(size(t)); zeros(size(t)); zeros(size(t))]; %u3(elevator) = 1, a step input
[y,t,x] = lsim(sys,u,t);
%plot
figure(1), plot(t,x(:,1)), title('pitch rate')
I am trying to apply a step input and an impulse ONLY to the elevator of the aircraft which is u3 (based on the 7 inputs from the B matrix). I am not sure if the lsim functon works by applying a step input only to the elevator as included in the code above or if there is a better way to do this (same for the impulse). Also, how to plot the response to this inputs?
Any help would be greatly appreciate it.
Thank you.

2 Comments

I think there is some problem in your state space model itself.
For a model with Nx states, Ny outputs, and Nu inputs:
  • A is an Nx-by-Nx real- or complex-valued matrix.
  • B is an Nx-by-Nu real- or complex-valued matrix.
  • C is an Ny-by-Nx real- or complex-valued matrix.
  • D is an Ny-by-Nu real- or complex-valued matrix.
Basically what I am trying to tell is that C and D should have same number of rows. Can you please check again.
@Raj, you are right. I actually modified the code a bit and forgot to make the C and D rows equal! I just fixed that. Any ideas on my actual question? Thanks.

Sign in to comment.

 Accepted Answer

The 'lsim' functon will work here. The code is correct and the input is getting applied only to the elevator (U3). If you are thinking why all the states are responding to only elevator input then this is expected because its a MIMO system and all the output states are coupled to each other. So basically there is no issue here.
However you can note a few minor things:
1) In this case you are checking open loop system response but I assume your next step will be to design a contoller here as the system is clearly unstable. Its always a good idea to let the plant settledown before applying any input in cases where you have some initial transient response. So in that case, after you define your input you can just make the input U3 zero for say 1 second before giving a step. Something like this:
u = [zeros(size(t)); zeros(size(t)); ones(size(t)); zeros(size(t));...
zeros(size(t)); zeros(size(t)); zeros(size(t))]; %u3(elevator) = 1, a step input
for i=1:127 % Till 127th sample i.e. 1 sec in this case
u(3,i)=0;
end
2) Your state space system 'sys' is basically a 9x7 ss matrix depending on your number of inputs (7) and number of output state vectors (9). Now if you want to see impulse response of third input U3 to first state vector X1(Pitch rate) then just use:
impulse(sys(1,3))
3) You are already plotting the time response of first state vector (Pitch rate). I see no issue there.

5 Comments

Awesome, thanks for the neat explanation! Actually, I do have a stable system but I did not use the real arcraft matrices in here. I just wanted to get a pointer if I was doing this correctly. And how to do an impulse response to only u3. I thought there might've been a function for the impulse that I could applied to only u3 but I guess there is not a specific one to do it this way, so I will do it as you suggested in applying a high value to u3. Thanks!
Hey buddy I have edited the answer for getting impulse response. The way I told earlier was not exactly correct. You cannot define a dirac delta function that way. Please see the new answer. Let me know if you need further explanation. Sorry for the error!
Great! It would be the same for the step response right? I could just do step(sys(1,3))? Also, what is the 1 representing? the first state's response to the step/impulse applied to the elevator? (I have 4 states).
Thanks!
Yes, step also can be done in same way. You are correct about the '1' also. The same thing that you have used in your plot command plot(t,x(:,1)) i.e. the first state (Pitch rate) out of the four states. Glad we both learned something today. Cheers!

Sign in to comment.

More Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Asked:

J
J
on 2 May 2019

Commented:

J
J
on 3 May 2019

Community Treasure Hunt

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

Start Hunting!