Exercises 16.06 16.07 Matlab Simulink
Exercises 16.06 16.07 Matlab Simulink
edu
Alternatively, on Athena:
athena% add acmath athena% cp /mit/acmath/matlab/course16/matlab_simulink_tutorial.tar .
2. Extract this sessions sub-directories and files On Athena (or the UNIX shell on Mac OS X):
tar xvf matlab_simulink_tutorial.tar
On laptops:
Use your computers utilities, such as double click or WinZip on Windows or StuffIt on Mac. Your local work directory matlab_simulink_tutorial should now contain the following directories and files: matlab_simulink_tutorial Exercise1 odeLanderVelocity.m MarsLander.m longTimeResponse.m f8long.m Exercise2 f8.mdl
On laptops:
Launch MATLAB and navigate to the work directory matlab_simulink_tutorial.
16.06 & 16.07 Fall 2007 | MATLAB & Simulink Tutorials | [email protected]
Problem
Compute the velocity, v, and acceleration, dv/dt, for the last stage of landing (after the retrorockets are launched) for a Mars Lander with mass m=150 kg and drag coefficient k=1.2. The gravity constant on Mars is 3.688 m/s2. Plot v and dv/dt vs. time on the same plot and show that the acceleration approaches zero as the velocity approaches a terminal velocity value.
For another Dynamics example for 16.07, see files getF.m and Central_Force_Motion.m.
16.06 & 16.07 Fall 2007 | MATLAB & Simulink Tutorials | [email protected]
x = Ax + Bv
where the variables in the x vector are called state variables and define the state of the aircraft at any time, while the v vector contains the control variables. The following state variables represent perturbations from an equilibrium condition: q(t) is the pitch rate (deg/s) u(t) is the perturbation of horizontal velocity (ft/s) (t) is the perturbation of the angle of attack from trim (deg) (t) is the perturbation of the pitch angle from trim (deg) The control variable is e: the elevator deflection (deg) from equilibrium (trimmed) condition. When the equations are written in the following form, they are said to be in State Space form:
i
x = Ax + Bv y = Cx + Dv
where y is the output vector (which could be the same as or different from x). A, B, C, and D are called state, input, output, and feedthrough matrices, respectively. The free longitudinal response of an aircraft can be studied by setting the control input to zero:
i
x = Ax
Two natural modes of the system, called Short Period mode and Phugoid mode, are related to the eigenvalues of the matrix A.
16.06 & 16.07 Fall 2007 | MATLAB & Simulink Tutorials | [email protected]
Problem
The following linear differential equations model the longitudinal motions of the F-8 aircraft:
q ( t ) = 0.7q ( t ) 0.0344u ( t ) 12 ( t ) 19 e ( t ) u ( t ) = 0.014u ( t ) 0.290 ( t ) 0.562 ( t ) 0.0115 e ( t )
i i
Define the state and input matrices A and B for the State Space form of the system. Compute the transfer functions relating the state variables to the control input. Compute and plot the change over time of the elements of the state vector x due to a perturbation in the elevator angle, e.
16.06 & 16.07 Fall 2007 | MATLAB & Simulink Tutorials | [email protected]
Background
In this exercise, we will be designing a controller for the longitudinal dynamics of the F-8. The transfer function of the horizontal speed of the F-8 to the elevator angle is approximately:
G (s) =
The controller takes the error in the speed as input and outputs the elevator angle. The F-8 dynamics then converts this elevator angle to airspeed. We will also model a sensor, which will have a small amount of lag. We are modeling the behavior of the system when the desired speed suddenly changes, which will be represented with a step function as input.
Problem
Create the Simulink model shown in the figure below (also saved in file f8.mdl). Run the simulation. Change the transfer function of the controller and re-run the simulation. Repeat until the output has improved.
16.06 & 16.07 Fall 2007 | MATLAB & Simulink Tutorials | [email protected]
Add a step function input to the model: use Step Function from the Sources library. Add a scope to the model: use Scope from the Sinks library. Add three transfer functions to the model: Transfer Fcn from the Continuous library. Change the names of the transfer functions to Controller, Aircraft, and Sensor. Add a sum operator to the model: Sum from the Math Operations library. Change the sum operator to perform subtraction rather than addition. (Double click on the operator and change the list of signs to |+ - in the Block Parameters: Sum window). Change the transfer function of the aircraft. (Double click on the aircraft icon and change the nominator and denominator using MATLAB matrix notation in the Function Block Parameters: Aircraft window. In this exercise both the nominator and denominator are row vectors that represent the coefficients of a polynomial in decreasing exponent of s.) 1 Change the transfer function of the sensor to (i. e. a sensor with 0.01 sec lag). 0.01s + 1 Add an output to the MATLAB plot interface: To Workspace from the Sinks library. Connect the blocks of the model as shown in the figure.
2.5s . 0.15s + 1 Run the simulation again and observe the output of the scope. Has the new controller improved the output? Your model should now look like this:
Change the transfer function of the controller to
In the MATLAB command line window, type the command who to see the variables in the workplace. Then plot simout vs. tout. What does this plot look like? 6