Experiment 1 of Modern Control Theory Course: State Space Analysis and Motion Solution of Linear System

insert image description here

1. Purpose of the experiment

insert image description here

Master the standard form, solution and model transformation of the linear system state space.

2. Experimental equipment and software:

MATLAB numerical analysis software

3. Experimental principle:

3.1. Command format for finding matrix eigenvalues ​​and eigenvectors

[VJ]=eig(A)
cv= eig(A)
Explanation: V eigenvector, J is Jordan type; cv is eigenvalue column vector

3.2. The method of seeking motion

(1) Utilize Laplace inverse transform----suitable for continuous/discrete linear systems

Use ilaplace/iztrans to find the inverse of the transfer function, this method is generally to find the response in the case of zero input.

(2) Use continuous (discrete) state transition matrix to represent the analytical solution of the system - suitable for linear steady systems

For continuous linear steady systems there are:
insert image description here

Obviously, there are many methods to calculate the system state transition matrix, such as definition method, Laplace transformation method, Sylvester method.
In Matlab, the method of Pade approximation is adopted, and the calling format is: phi=expm( ).
For discrete linear invariant systems:
insert image description here

3.3. Numerical integration method of state equation - suitable for continuous linear and nonlinear systems

Various steady/time-varying and linear/nonlinear systems can be easily handled by direct numerical integration. There are many numerical integration methods, among which there is a type of prediction-correction numerical integration method + adaptive step size adjustment algorithm that is more effective. A variety of effective and applicable to different types of ODE (Ordinary Differential Equations) solving algorithms contained in Matlab/Simulink, typically the Runge-Kutta algorithm, the commonly used function format is as follows:

[t,x] = ode45(odefun,[ti,tf],x0,options)----采用四阶、五阶Runge-Kutta算法
[t,x] = ode23(odefun,[ti,tf],x0,options)----采用二阶、三阶Runge-Kutta算法

Explanation: a. These two functions are functions for solving non-rigid ordinary differential equations, and there are some methods for solving rigid ordinary differential equations, such as ode15s ode23s ode23t ode23tbetc.
b. The parameter options is the error setting of the integral, and the values ​​are relative error 'reltol' and absolute error 'abstol'; [ti,tf] is the time range for solving; x0 is the initial value vector; [t,x] is the solution.
c. The Runge-Kutta algorithm is the most commonly used numerical method, please refer to the relevant information, read the principle of the algorithm and the calculation format.
Below is an example:
insert image description here

3.4. Using the discretization solution function in Cotrol ToolBox - suitable for LTI system

a. Use the step()/impulse() function to find the state response of the system when step input/impulse input:

When the system G is continuous:
calling [y,t,x]=step/impulse(G) will automatically select the sampling time range and sampling period for the continuous system G;
calling [y,t,x]=step/impulse (G,ti:Ts:tf) The sampling time range and sampling period of the continuous system G are defined by the user.
When the system G is discrete:
calling [y,t,x]=step/impulse(G) will be calculated according to the sampling period given by the discrete system G;
calling [y,t,x]=step/impulse(G , ti:Ts:tf), Ts must be consistent with the sampling period given by the discrete system G.

b. Use the lsim() function to obtain the state response of the system for any input

Call format: [y,x,t]=lsim(G,u,ti:Ts:tf,x0) (pay attention to the situation of continuous system and discrete system)

c. The initial() function can be used for zero input response

Call format: [y,x,t]=initial(G,x0) (pay attention to the situation of continuous system and discrete system)

3.5. Use the Simulink environment to obtain the response----suitable for all systems to obtain the response

Use Simulink to find the response of a linear or nonlinear system

The calling format is as follows: [t,x,y]=sim('XX.mdl', ti:Ts:tf, options,u)

4. Experimental content

known linear system
insert image description here

The experimental procedure is as follows

clear
A = [ -21 19 -20; 19 -21 20; 40 -40 -40]; 
B = [ 0; 1; 2];
C = [ 1 0 2];
D = [0];

stateSpace = ss(A, B, C, D);    % 状态空间表达式

% 阶跃响应
[stepOutResponse, stepTime, stepResponse] = step(stateSpace);

% 冲激响应
[impulseOutResponse, impulseTime, impulseResponse] = impulse(stateSpace);

figure(1);
subplot(2, 1, 1);
plot(stepTime, stepResponse);
title('阶跃响应状态响应曲线');
grid on;
 
subplot(2, 1, 2);
plot(stepTime, stepOutResponse);
title('阶跃响应输出响应曲线');
grid on;

figure(2);
subplot(2, 1, 1);
plot(impulseTime, impulseResponse);
title('冲激响应状态响应曲线');
grid on;
 
subplot(2, 1, 2);
plot(impulseTime, impulseOutResponse);
title('冲激响应输出响应曲线');
grid on;

t =[0: 0.01: 5];
u = (1 + exp(-t) .* cos(5 * t)).*(t<3) + 1 * (t>= 3);
t = t'; u = u';
ut = [t, u];
[t1, x, y] = sim('shiyan.mdl', t, [], ut);

figure(3);
subplot(2, 1, 1);
plot(t1, x);
title('状态响应曲线');
grid on;

subplot(2, 1, 2);
plot(t1, y);
title('输出响应曲线');
grid on;

 % 传递函数
[num, den] = ss2tf(A, B, C, D, 1); 
transferFunc = tf(num, den);

figure(4);
rlocus(transferFunc);
title('K增益负反馈闭环根轨迹图');
grid on;

figure(5);
bode(transferFunc);
title('系统的bode图'); grid on;

figure(6);
nyquist(transferFunc);
title('系统的Nyquist图');
grid on;
  • Use Matlab to calculate the step response (including state and output) in the zero state, and generate two graphs: the first graph draws the response curves of each state and marks them; the second graph draws the output response curves.
    insert image description here

  • Use Matlab to calculate the impulse response (including state and output) in the zero state, and generate two graphs: the first graph draws the response curves of each state and marks them; the second graph draws the output response curves.
    insert image description here

If the control input is

insert image description here

and the initial state is

insert image description here

Ask for the response of the system, requesting

  • a. Draw the model in Simulink to find the response, and generate two graphs: the first graph draws the response curves of each state and labels them; the second graph draws the output response curves.
    insert image description here

  • system transfer function
    insert image description here

  • Use K gain negative feedback to draw a closed-loop root locus diagram
    insert image description here

From the root locus, the first one tends to the source point, the second one tends to be between 20-60, and the third one tends to infinity.

Draw Bode diagram and Nyquist diagram in Matlab
insert image description here
insert image description here

For the bode diagram, it can be known that the crossover frequency is after the corner frequency, so the system response changes in the low frequency band. For phase frequency, the phase frequency characteristics of the system are all negative. According to the Nyquist diagram, the system is stable.

5. Experimental summary

insert image description here

5.1. Experimental principle

The state space model of linear steady continuous system can be solved in Matlab:

  • The step response function step() can be used to compute the output response of a transfer function model, or the state and output responses of a state space model, at a unit step input and zero initial state (condition).
  • The simulation function impulse() under impulsive excitation can be used to compute the output response of a transfer function model, or the state and output responses of a state space model, under an impulsive stimulus input.
  • The simulation function lsim() under arbitrary input excitation can be used to calculate the output response of the transfer function model under a given input signal sequence (sampled values ​​of the input signal function).

5.2. Experimental summary

Through this experiment,

  • Mastered the use of state space expressions and transfer functions of linear systems in MATLAB.
  • Know how to build a system simulation model of the state equation in simulink.
  • And how to find the states of the state variables in the state space after various responses, how to establish the simulation model of the state space system, etc.
    insert image description here

Guess you like

Origin blog.csdn.net/m0_47419053/article/details/127337637