Lindsey Hines Final Report

download Lindsey Hines Final Report

of 21

Transcript of Lindsey Hines Final Report

  • 8/3/2019 Lindsey Hines Final Report

    1/21

    Hovercraft Kinematic Modeling

    Lindsey HinesClass of 2008

    Dr. Michael P. Hennessey

    Center of Applied Mathematics

    University of St. Thomas

    September 23, 2005

    1. Target Audience and Key Terms

    This report is intended for those who have taken and successfully completed Calculus IIor the equivalent mathematics course. Knowledge of physics of at least an introductory level is

    also assumed. Potentially unfamiliar terms used in this report are as follows: state-space model,

    Matlab/Simulink, open-loop simulation, closed-loop simulation, eigenvalue, and linear

    approximation.State-space models represent the dynamics of physical systems described by a series of

    first order coupled differential equations. In the general state-space model, x is the state vector

    and is the output. The set of equations are given by:y

    DuCxy

    BuAxx

    +=

    +=&

    The vector x is of dimension n by 1 containing the state variables which often represent position

    and velocity. The matrix represents the input variables, usually forces in mechanical systems.The remaining matrices, A, B, C, and D, determine the relationships between the state, input and

    output variables.

    u

    Matlab, short for Matrix Laboratory, is a computer program designed for easy matrix

    manipulation. Simulink is integrated within Matlab and allows model design and simulation.

    Models in Simulink are created with linked blocks in a form similar to analog computers.Open-loop simulations are simulations run without any feedback; no control is placed on

    the system. Closed-loop simulations are those run with feedback with the aim of controlling the

    system. One example of a closed loop system is a rocket launch: as position/velocity/orientationchanges, these values are fed back into the system with the appropriate gains to create a straight

    flight path.

    Eigenvalues are formally described as follows:

    Let A be an n-by-n matrix of complex or real numbers. C is an eigenvalue ofA with eigenvector if is not zero andnCv v vAv = .

    Eigenvalues can be used to determine the stability of a system. Eigenvalues in the open right

    half of the complex plane indicate instability; in the open left half plane they signify stability.

    When lying on the imaginary axis they indicate a marginally stable system.

  • 8/3/2019 Lindsey Hines Final Report

    2/21

    Linear approximation allows nonlinear mechanical systems to be analyzed with toolsused for studying linear systems. Nonlinear systems can be linearized around an operating point

    of interest and their local stability analyzed.

    2. Problem Statement

    The aim of this project was to create an accurate mathematical model of a hovercraftsmotion. The hovercraft used was a standard remote control version which functioned on the

    same principles as the large commercial variety. Further objectives were to achieve correlation

    between the computer-run simulations and experimental runs, to form a foundation for furtherapplications, and to prepare groundwork for Dr. Hennesseys J-term kinematics class.

    Image of the remote control hovercraft modeled.

    3. Research Goals

    The first objective was to develop the equations of motion to represent the hovercraftdynamical system. With the equations of motion determined, parameters of this particular

    situation could be evaluated. Certain parameters can easily be measured, but others requireestimation. The next aim was to create experiments to estimate these hard to define parameters.

    Experiments were required for both the viscous friction coefficients and the moment of inertia.

    Once completed, the system could be placed in Matlab and Simulink and simulations run. Aspart of our research goal, it is necessary to test for realism. Running a series of open loop

    simulations and experimental runs was planned to accomplish this. If time allowed, further work

    on stabilization in some form was desired for the hovercraft system.

    4. Results and Methodology

    A. Equations of Motion

    The equations of motion, the first and most essential step in developing the hovercraftmathematical model, represent movement on a two dimensional plane. The hovercraft had two

    thrust fans and one lift fan; the thrust fans provided two separate sources of input represented by

    the variables and . The following diagram depicts hovercraft location and

    orientation

    1F 2F

    ),,( yx along with the sites of possible applied force.

  • 8/3/2019 Lindsey Hines Final Report

    3/21

    F1

    F2

    ),( yx

    y

    xO

    The equations of motion include three velocity variables and three acceleration variables

    which are first represented by and respectively. Defining their relationship

    was possible with derivation from Newtons second law

    ),,( &&& yx ),,( &&&&&& yx

    = maF .

    Frictionless case derivation:

    = maF

    In the x direction:

    xmFF &&=+ cos)( 21

    m

    FFx

    cos)( 21 +=&&

    In the y direction

    ymFF &&=+ sin)( 21

    m

    FFy

    sin)( 21 +=&&

    = I

    Rotational motion:

    (with counterclockwise torque positive)

    &&IFFd = )( 12

    I

    FFd )( 12 =&&

    Considering viscous friction and altering the equations into first order form, the finished array isa series of coupled differential equations and considered to be in standard state-space form. The

    subsequent equations are the basis of the hovercraft mathematical modeling.

    I

    b

    I

    FFd

    m

    bv

    m

    FFv

    m

    bu

    m

    FFu

    vy

    ux

    )(

    sin)(

    cos)(

    12

    21

    21

    =

    +

    =

    +

    =

    ==

    =

    &

    &

    &

    &&

    &

  • 8/3/2019 Lindsey Hines Final Report

    4/21

    The parameters that are yet undefined are mass ( m ), half the distance between the fans ( ),

    moment of inertia (

    d

    I), translational viscous coefficient of friction ( ) and rotational viscous

    coefficient of friction ( ).

    b

    b

    A more generalized form, with only the left hand side of the equations represented, can

    provide a better description of the system as a whole.

    ]),,[;,( GIfUXfX =& = ],,,,,[ vuyxX

    X: State-space vector containing the state variables. The first three variables represent the

    location of the hovercraft, the last three the hovercrafts velocity in the x direction, y direction,

    and its rotational velocity.

    = ],[ 21 FFU U: Force input from thrusters

    f : Friction parameters

    I: Inertia parameters

    G : Geometric parameters

    B. Defining Parameters

    The parameters were defined using both simple measuring tools and more complex

    experiments. Determining the mass was accomplished with an electronic scale (0.994kg),maximum force imparted by the fans was assessed by a spring gauge (1.5N), and half the

    distance between the fans was measured with a ruler (0.56m). The friction and inertia

    parameters were determined experimentally.Because the hovercraft rides on a cushion of air and has little contact with the ground,

    only viscous friction (fluid friction or in this case air resistance) was considered. Including

    Columbic friction in the model was considered but proved too difficult for the allotted time. The

    viscous translational coefficient of friction was estimated with an experiment governed by the

    differential equation , while rotational motion was governed byxbxm &&& = &&& bI =

    xbxm &&& = &&& bI =

    First order form: First order form:

    vx =& v=&

    0=+mbvv& 0=+

    Ivbv &

    Solution: Solution:

    m

    bt

    evv

    = 0 I

    tb

    evv

    = 0

    0v : initial velocity : initial velocity0v

  • 8/3/2019 Lindsey Hines Final Report

    5/21

    With a final velocity ( v ) equal to zero, velocity descends exponentially from max towards zero

    over time. By substituting 5 for time to stop ( in this case being ), one can solve for

    the translational viscous coefficient.

    bm/*5

    Tstop

    m

    b

    5

    By bringing the hovercraft to a determined top speed in a straight line and allowing it to coast to

    a stop, Tstop can be measured and estimated. The subsequent figure plotsb mbt

    evv

    = 0 for the

    hovercraft. Choosing 5 to represent stopping time proved to be reasonable; the stopping time

    experimentally was 23 seconds, a point at which the plot shows a velocity close to zero. The

    measured translational viscous coefficient was 0.22 kg/sec.

    0 5 10 15 20 25 300

    1

    2

    3

    4

    5

    6

    time (sec)

    velocity(m/s)

    0v

    5 = Tstop

    Determining the rotational coefficient of viscous friction was accomplished with a verysimilar method except that instead of the hovercraft beginning with a maximum translational

    velocity, it begins the experiment with its greatest rotational velocity. The measured rotational

    viscous coefficient was 0.03 (kg m2)/sec.

    Like the viscous coefficients, the moment of inertia had to be estimated experimentally.

    One difficulty that arose was the natural distribution of mass in the hovercraft. A weight was

    added to the front of the hovercraft in an attempt to counteract the weight of the two rear fans,but it was successful in only a limited extent; the moment of inertia became easier to measure but

    the drag against the floor caused by the mass imbalance was only reduced, not eliminated.

    The experiment to estimate the hovercrafts moment of inertia came from Ogatas System

    Dynamics text [1]. The governing differential equation is as follows:

    02

    =+ Ih

    mga&& 0)0(0)0( = &

  • 8/3/2019 Lindsey Hines Final Report

    6/21

    The hovercraft was suspended from two wires equally spaced from the center of gravity.

    Disturbed slightly from its resting position, the hovercraft made small oscillations about a

    vertical axis. The variable represents the hovercrafts orientation while & represents angular

    velocity. By timing the rotations after the release, the period could be found and consequently

    the moment of inertia. The measured moment of inertia was 0.021 kg m2.

    Once integrated and solved for I:

    h

    mgaTI

    2

    2

    =

    I= moment of inertia

    a2 = distance between the wires

    h = length of the wires

    Experimental setup:Two suspending wires

    Image of suspended hovercraft an animated version included with the links to this paper.

    C. Simulations

    With the equations of motion determined and the parameters defined, the model was nowready to be placed into code. To create easily adjustable input values, the force created by each

    fan was parameterized by blocks of time and given the value of either 1.5 N (maximum) or zero.

    While the fans in truth do not instantly translate from stopped to full blast, for the purposes ofour model this assumption was satisfactory. Utilizing mfiles in Matlab the equations were

    integrated in a standard ordinary differential equation solver (ode23), their output producing

    graphical representations of different maneuvers. These mfiles and others can be found in theappendix.

    The model was then transferred into Simulink which is better suited for simulations,

    including eventual control simulations. The following diagram represents the equations of

    motion in block diagram form. This series of blocks is named the Hovercraft Subsystem and is apart of the greater Simulink model.

  • 8/3/2019 Lindsey Hines Final Report

    7/21

    Hovercraft Subsystem: each block is labeled, describing its function.

    The complete model in Simulink can be seen in the next diagram. In the center light red

    block lays the Hovercraft Subsystem. On the top right of this block the fan inputs enter the

    system while the variables to be integrated exit on the left. Each red block on the left side of themodel holds a different set of fan inputs. When the simulation is run, only one of these blocks is

    fed into the system; each red block produces a different hovercraft maneuver. The selected

    maneuver can be viewed by both the blue scopes on the right, which plot the state variables over

    time, and the figures created in Matlab once the variables are sent back into the workspace.All of the simulations run with this model are open loop; examining the diagram one can

    see that there is no feedback to alter the input variables and . The commands for each

    hovercraft maneuver were determined by trial and error.1F 2F

  • 8/3/2019 Lindsey Hines Final Report

    8/21

    Simulink Open Loop Model

    While not complex, maneuvers such as left and right turns, straight line motion, and

    spirals allow an essential test for realism: the test of common sense. For example, if both fanswere turned on, the hovercraft was expected to travel forward on a straight path; if the hovercraft

    is given an initial rotational velocity, it should spin and slow to a stop. The model passed this

    test with no difficulty.The open loop maneuvers also allowed the opportunity for more strenuous tests with the

    use of obstacle courses. Two different courses were run in Matlab, each requiring a greater

    degree of precision then any basic turns or loops.

    Fan inputs for obstacle course #1

  • 8/3/2019 Lindsey Hines Final Report

    9/21

    Hovercraft position over time in obstacle course #1

    FINISH

    START

    The first course required both a left and right turn in a limited space. The red lines are the course

    walls while the blue line is the course of the hovercraft.

    Fan inputs for obstacle course #2

  • 8/3/2019 Lindsey Hines Final Report

    10/21

    Hovercraft position over time in obstacle course #2

    FINISH

    START

    The second course emphasized orientation. The hovercraft began facing parallel to the y-axis

    and ended traveling in the positive y direction through a gate at the finishing point.

    Two video clips can be viewed of the maneuvering hovercraft; they can be found among

    the links with this report. The first demonstrates the difficulty of control speed of thehovercraft increases quite rapidly and crashes are not uncommon. The second clip shows a trialrun through the first obstacle course. While the inputs used were not the exact fan inputs

    described in the Matlab simulation, they were close. In fact the order of left right fan inputs was

    correct; only the exact length of thruster firing altered slightly. This could be contributed to

    human error since it was an individual who attempted to reenact the simulation inputs instead ofa computer. More likely however, it was a combination of this and the need for slight alterations

    of the model.

    D. Stabilization

    With the success of open loop modeling, the opportunity to close the loop arose. First the

    model was linearized to check for stability. If linear stability had been shown to be absent,closing the loop would have been more difficult. Fortunately this was not the case.

  • 8/3/2019 Lindsey Hines Final Report

    11/21

    Linear model (with , , and1F 2F small):

    I

    b

    I

    FFd

    m

    bvv

    m

    bu

    m

    FFu

    vy

    ux

    )(

    )(

    12

    21

    =

    =

    +=

    =

    =

    =

    &

    &

    &

    &

    &

    &

    Linear model in matrix form:

    A B

    +

    =

    2

    1

    00

    11

    00

    00

    00

    00000

    00000

    00000

    100000

    010000001000

    F

    F

    Id

    Id

    mm

    v

    u

    y

    x

    Ib

    mb

    mb

    v

    u

    y

    x

    &

    &

    &

    &

    &

    &

    The eigenvalues of A were found to assess the models stability.

    mb I

    b mb=

    0 00

    Since three were negative and three were zero, the model is marginally stable. Stabilization in

    some form was possible.

    The first attempt to create feedback for the model used y and the sign of to coerce the

    hovercraft to move along the x-axis. This was unsuccessful. The next attempt was manipulating

    the linear model, feeding back a series of variables. Eventually the model was altered to

    feedback u and which, upon a controllability analysis, proved to be successful.

  • 8/3/2019 Lindsey Hines Final Report

    12/21

    Adjusted linear model:

    XFX * = X

    =

    v

    u

    y

    x

    u

    100000

    001000

    F*X

    +

    =

    2

    111

    0

    0

    F

    F

    Id

    Id

    mmu

    Ib

    mb

    u

    &

    &

    *U*X*X& *A *B

    General controllability of a linear system:

    ... 1BAABBE n= while A is an nn matrix

    If E is full rank then the system is controllable

    In this case:

    **,...*,**,* 1BABABE n=

    11

    *

    22

    22

    =

    I

    db

    I

    db

    Id

    Id

    mb

    mb

    mmE

    & rank(E*) = 2 = dim( *X )

    The rank of E* is equal to two. Since E* is full rank, the system is controllable.

    The linear model was used as a first step in the process to control the nonlinear hovercraft

    model. In the linear model the state variables used were now the deviation from the state

    variables ( ). The objective was to have],[X* = u u and go to zero from nonzero

    initial conditions. With rotational velocity and velocity in the x direction stabilized, the

    hovercrafts path could be controlled along a straight line from the origin.The first variable in each equation is the nonlinear state variable. Each is equal to their

    respective operating point values plus their perturbation (shown in the linear model). The

    operating point is the desired value for the state variables. Since the desired controlled path istraveling along a straight line, the translational velocity in the x direction, , cannot be equal to

    zero.

    0u

  • 8/3/2019 Lindsey Hines Final Report

    13/21

    Operating point:

    +=

    +=+=

    +=

    +=

    +=

    0

    0

    0

    0

    0

    0

    vvv

    uuu

    yyy

    xxx

    =

    =

    0

    0

    5

    0

    0

    0

    0

    0

    0

    0

    0

    00 u

    X

    Closed-loop block design:

    ***** UBXAX +=& ** XKU =

    ** XY =

    ***** XKBXAX +=&

    *)**(* XKBAX +=&

    Apply Laplace Transform:

    0])**[det( =+ KBAsI

    From which closed-loop poles are determinant.

    Conceptual block diagram of the closed-loop control system for the straightening out

    maneuver:

    cX**X

    *X

    K

    ** XX c

    ***** UBXAX +=&

    ** XY =+

    0

    0

    Initial Conditions:

    )0(

    )0(

    u

  • 8/3/2019 Lindsey Hines Final Report

    14/21

    The matrix K is used to place the poles of the closed-loop system in the open left hand planeusing the Matlab place command. The system was placed into the block diagram form shown

    below. The green block in the center holds the adjusted linear model in matrix form. The white

    triangle-shaped block holds the gain matrix (K); as long as the poles were in the left hand plane,

    u and would be brought to the value of their respective commands seen in the orange

    blocks on the left side of the diagram.

    delta x (m)

    delta theta (rad) delta omega (rad/s)

    0

    U_cZ

    To Workspace

    x' = Ax+Bu

    y = Cx+Du

    State-Space0

    Omega_c

    1

    s

    Int. delta x

    1

    s

    Int. delta theta

    K* u

    Gain

    Full plot

    F2

    F1

    delta u (m/s)

    The plots below graph the outputs of the above linear model over ten seconds. The desired

    values of both u and were achieved.

  • 8/3/2019 Lindsey Hines Final Report

    15/21

    The next challenge was to place these controls on the nonlinear system. The andu

    commands and the gain matrix K are applied to the nonlinear system in much the same way as

    the linear system. However, since the operating point was , a velocity

    of 5 meters per second in the x-direction, a value of -5 was added to the feedback block string.

    In addition, a value of .55N was added both fan forces before being fed into the system to ensure

    the hovercrafts motion would continue.

    = ]0,0,/5,0,0,0[0 smX

    u

    y (m)

    x (m)

    v (m/s)

    u (m/s)

    t he ta (ra d) o me ga ( m/ s)

    XY Graph

    5

    U_op

    0

    U_c

    Z

    To Workspace

    0

    Omega_op

    0

    Omega_c

    1

    s

    Int. y

    1

    s

    Int. x

    1

    s

    Int. w

    1

    s

    Int. v

    1

    s

    Int. u

    1

    s

    Int. theta

    F1

    F2

    theta

    u

    v

    omega

    u dot

    v dot

    omega dot

    Hovercraft

    Subsystem

    K* u

    Gain

    Full Plot.55

    F_

    .55

    F_

    F2

    F1

    F2

    To Workspace

    F1

    To Workspace

    The following plots are the graphical results of the closed-loop nonlinear system. The desired

    operating point was met, controlling the hovercraft in a straightening out maneuver.

  • 8/3/2019 Lindsey Hines Final Report

    16/21

  • 8/3/2019 Lindsey Hines Final Report

    17/21

    7. Conclusions

    Overall this research has achieved the desired goals. A mathematical model wassuccessfully created of the remote control hovercraft with a decent degree of accuracy. The

    nonlinear system was successfully stabilized which leaves interesting opportunities for further

    applications and good groundwork has been created for Dr. Hennesseys kinematics class.

    6. Future Directions

    Much was achieved but there are a few more interesting avenues two explore with this

    research. Refinement on the mathematical model could be made. One possibility would be

    incorporating Columbic friction into the equations of motion, allowing hovercraft dynamics to bebetter predicted. Another interesting project would be to continue and expand hovercraft

    stabilization. Perhaps sensors could be added to the hovercraft for improved feedback values for

    closed loop control. At the present time Dr. Hennesseys J-term kinematic class will continue towork on hovercraft kinematic modeling with the addition of CAD/Solidworks projects for the

    visualization of the motion.

    Bibliography

    [1] K. Ogata, System Dynamics, Prentice Hall, 1997.

    Appendix

    1. vf2.m

    This program defines the function zprime (also known as X& ) and holds the fan input

    values for each simulation. For each trial the function remains the same: only the if statementsare altered in the program to reflect fan forces for different lengths of time.

    function zprime = vf2(t,z)

    if t < .5F1 = 1.5;F2 = 1.5;

    elseif t < 2F1 = 1.5;F2 = 0;

    elseif t < 2.5F1 = 1.5;

    F2 = 1.5;elseif t < 4

    F1 = 0;F2 = 1.5;

    elseif t < 4.5F1 = 0;F2 = 0;

    elseif t < 5.5F1 = 1.5;F2 = 1.5;

    elseif t < 6

  • 8/3/2019 Lindsey Hines Final Report

    18/21

    F1 = 0;F2 = 1.5 ;

    elseif t < 7F1 = 1.5;F2 = 1.5;

    elseF1 = 0;F2 = 0;

    end

    d = .056;m = .994;I = .021;b = 0.22;btheta = 0.03;

    zprime(1) = z(4);zprime(2) = z(5);zprime(3) = z(6);zprime(4) = ((F1+F2)*cos(z(3)))/m - (b*z(4))/m;zprime(5) = ((F1+F2)*sin(z(3)))/m - (b*z(5))/m;zprime(6) = (d*(F2-F1))/I - (btheta*z(6))/I;zprime = zprime(:);

    2. vf2run.m

    This program calls upon the function defined in vf2.m and differentiates it using ode23.Here the length of the trial can be changed as well as the initial values for the state

    variables. This file also creates three different plots to show the results.

    clear;

    tmax = 7;tspan=[0:.01:tmax];z0=[.5 .5 pi/2 0 0 0]';[t,z]=ode23(@vf2,tspan,z0)

    subplot(3,1,1),plot(t,z)xlabel('time')ylabel('x, y, theta, u, v, w')legend('x = position in the x direction (m)','y = position in the y direction

    (m)','theta = rotation around centroid (radians)','u = velocity in the x

    direction (m/s)','v = velocity in the y direction (m/s)','w = rotational

    velocity (radians/s)','Location','BestOutside'), gridtitle('state function z: representing movement of hovercraft')

    subplot(3,1,2),plot(z(:,1),z(:,2))xlabel('x direction')ylabel('y direction'),gridtitle('hovercraft position')axis equalhold onf = [0 0 8 8 0];g = [0 7.5 7.5 0 0];plot(f,g,'r')h = [0 6];j = [4.5 4.5];

  • 8/3/2019 Lindsey Hines Final Report

    19/21

    plot(h,j,'r')k = [2 8];l = [2 2];plot(k,l,'r')m = [.5 7.5];n = [.5 6];plot(m,n,'g*')hold off

    THETA = z(:,3);RHO = ones((tmax/.01)+1,1);Z = tspan;[X,Y,Z] = pol2cart(THETA,RHO,Z);subplot(3,1,3,'replace'),plot3(X,Y,Z),gridaz = -10;el = 60;view(az, el);axis([-1 1 -1 1 0 tmax])xlabel('x direction')ylabel('y direction'),grid

    title('hovercraft orientation over time')

    hold onZa = Z';tt=(tmax/.01)+1;quiver3(zeros(tmax+1,1),zeros(tmax+1,1),zeros(tmax+1,1),X(1:100:tt,1),Y(1:100

    :tt,1),Za(1:100:tt,1)),grid

    3. uomegaK.m

    The gain matrix (K) is defined in this file for the closed-loop Simulink simulations.

    d = .056;m = .994;I = .021;b = 0.22;btheta = 0.03;

    A=[-b/m 0 ;0 -btheta/I];B=[1/m 1/m;-d/I d/I];

    R = ((b/m)+(btheta/I))/2;Beta = pi/8;

    P1 = -R*(cos(Beta)+i*sin(Beta));

    P2 = conj(P1);

    P = [P1 P2];

    K=place(A,B,P)

    4. closedloopplot.m

    This file is for plotting variables defined in the Simulink closed-loop nonlinearsimulation.

  • 8/3/2019 Lindsey Hines Final Report

    20/21

    tmax = input('Enter length of trial in sec: ');

    t = 0:.1:tmax;

    subplot(5,2,1:2),plot(Z(:,1),Z(:,2))

    xlabel('x position (m)')ylabel('y position (m)'),gridtitle('Hovercraft position over time')

    subplot(5,2,3),plot(t',Z(:,1))xlabel('time (s)')ylabel('x (m)')title('Position in the x direction vs time')

    subplot(5,2,4),plot(t',Z(:,4))xlabel('time (s)')ylabel('u (m/s)')title('Velocity in the x direction vs time')

    subplot(5,2,5),plot(t',Z(:,2))xlabel('time (s)')ylabel('y (m)')title('Position in the y direction vs time')

    subplot(5,2,6),plot(t',Z(:,5))xlabel('time (s)' )ylabel('v (m/s)')title('Velocity in the y direction vs time')

    subplot(5,2,7),plot(t',Z(:,3))xlabel('time (s)')

    ylabel('theta (rad)')title('Rotation vs time')

    subplot(5,2,8),plot(t',Z(:,6))xlabel('time (s)')ylabel('w (rad/s)')title('Angular velocity vs time')

    subplot(5,2,9),plot(t',F1)xlabel('time (s)')ylabel('force (N)')title('F1 vs time')

    subplot(5,2,10),plot(t',F2)xlabel('time (s)')ylabel('force (N)')title('F2 vs time')

    5. linearclosedloopplot.m

    This file plots variables defined in the Simulink closed-loop linear simulation.

  • 8/3/2019 Lindsey Hines Final Report

    21/21

    tmax = input('Enter length of trial in sec: ');

    t = 0:.1:tmax;

    subplot(2,2,1),plot(t',Z(:,1))xlabel('time (s)')

    ylabel('delta x (m)')title('Deviation in the x direction vs time')

    subplot(2,2,2),plot(t',Z(:,3))xlabel('time (s)')ylabel('delta u (m/s)')title('Velocity deviation in the x direction vs time')

    subplot(2,2,3),plot(t',Z(:,2))xlabel('time (s)')ylabel('delta theta (rad)')title('Deviation in theta vs time')

    subplot(2,2,4),plot(t',Z(:,4))xlabel('time (s)')ylabel('delta w (rad/s)')title('Angular velocity deviation vs time')