1. Generals
  2. M-files
  3. Command
  4. Matrix
  5. Figure
  6. Symbolic Math Toolbox
  7. Solving Equations
  8. Simulink

  • Generals

  • M-file

  • Command

  • Matrix

  • Figure

  • Symbolic Math Toolbox

  • Solving Equations

    1. ODE (Ordinary Differential Equation)
      • reference (Korean)
      • writing Euler, Runge-Kutta function
      • using MATLAB function such as ode23, ode45 etc
      • using symbolic math toolbox (dsolve)
      • using simulink state space
      • using simulink integrator (1/s)
      Example : y' + y = 0; y(0) = 0.1
      function [y2]=odetosolve(t,y)
      command line
      options = odeset('RelTol',1e-4,'AbsTol',1e-5,'MaxStep',.05);
      [t,Y] = ode45(@odetosolve,[0 20],[.1],options);

    2. Polynomials
      Example : p(x) = x^3 - 2x^2 - x + 2
      p=[1 -2 -1 2];
      grid on

    3. Laplace transform
      Example :

  • Simulink

    From MIT Tutorial : F-8 longitudinal control system

    1. Start Simulink. Type simulink at the Matlab prompt.
    2. Start a new model. In the File menu of the Simulink library window, click "New" and then "Model".
    3. Add a step function to your model. In the Simulinklibrary window, double click the icon labeled "Sources". Drag the step function to the model window.
    4. Add three transfer functions to your model. In the library window, double click the icon labeled "Continuous". Drag transfer function to the model window 3 times.
    5. Add a scope to the model. A scope allows us to examine the output of the system. Double clickthe icon labeled "sinks".
    6. Add a sum operator to the model. The sum is in the "Math Operations" library.
    7. Change the sum operator so that it performs subtraction rather than addition. Double clickon the sum operator. A new window will appear with the title "BlockP arameters:Sum" Change the list of signs to "|+-" and click"OK".
    8. Change the name of the transfer function to "Controller" , "Aircraft" and the third to "Sensor". Click on the name, "Transfer Fcn", delete the existing name, and type Controller.
    9. Connect the step function to the summer. The small triangle on the right side of the step function represents the output. Clickon the small triangle and hold the mouse down. Hold the cursor over the input triangle to the sum icon’s positive input and release the mouse button.
    10. Connect the output of the sum to the input of the controller, the output of the controller to the input of the aircraft, and the output of the aircraft to the input of the scope.
    11. Flip the orientation of the sensor. Select the sensor blockb y clicking on it. In the "Format" menu, select "Flip Block."
    12. Create a feedbacklo op. Hold down the control key and click somewhere on the arrow between the aircraft blockand the scope. A dashed line will appear; connect it to the input of the sensor. Connect the output of the sensor to the negative input of the sum operator.
    13. Change the aircraft transfer function.Double clickthe aircraft icon. The numerator and denominator have to be set using Matlab matrix notation. We will be using only single-input single-output (SISO) transfer functions, so both the numerator and denominator will be row vectors. The vectors represent the coefficients of a polynomial in order of decreasing exponent of s. So, for our denominator 976s2 + 11.25s + 1, the vector is [976 11.25 1]. Enter [976 11.25 1] in the "denominator" field. Enter 964 in the numerator field.
    14. We will model the sensor as having a 0.01 second lag in reporting the speed. A simple lag of &tau seconds is represented by the transfer function H(s) = 1/(&tau s+1). Change the transfer function of the sensor to 1 / ( 0.01s+1 ).
    15. Set the simulation to run for 30 seconds. On the "Simulation" menu, click "Configuration Parameters". Fill in the "stop time" field with 30.
    16. Open the scope window. Double clickthe scope icon.
    17. Run the simulation. In the "Simulation" menu of the model window, click "Start".
    18. Examine the output of the simulation. Return to the scope window. To get the scope to show the most appropriate scale, clickthe binocular icon in the scope toolbar. Notice how the speed varies in response to a step input.
    19. Try a different controller. Change the transfer function of the controller to 2.5s 0.15s+1. Note that to get 2.5s as the numerator, the vector is [2.5 0].
    20. Re-run the simulation and observe the output of the scope. Has the new controller improved the output?
    21. Now we would like to plot the output in the standard Matlab plot interface. From the "Sinks" library, add a new "To Workspace" icon. Connect it to the output signal. Double clickthe "To Workspace" icon and change the "save format" to "array"
    22. Run the simulation.
    23. Return to the Matlab command window. Type who to see a list of variables available to you. Note that there are two new variables: tout and simout. These are the time and output signals from the simulation.
    24. Plot the output signal agains the time.
    25. Save the Simulink model. In the "File" menu of the model window, click on Save. Browse to an appropriate directory and save the model as "F8.mdl".