PARAMETER IDENTIFICATION, MODELING, AND SIMULATION OF A CART AND PENDULUM

Similar documents
Section 8.5. z(t) = be ix(t). (8.5.1) Figure A pendulum. ż = ibẋe ix (8.5.2) (8.5.3) = ( bẋ 2 cos(x) bẍ sin(x)) + i( bẋ 2 sin(x) + bẍ cos(x)).

Lab 6a: Pole Placement for the Inverted Pendulum

AP Physics. Harmonic Motion. Multiple Choice. Test E

TOPIC E: OSCILLATIONS EXAMPLES SPRING Q1. Find general solutions for the following differential equations:

Engineering Mechanics Prof. U. S. Dixit Department of Mechanical Engineering Indian Institute of Technology, Guwahati Introduction to vibration

Physics 201 Exam 3 (Monday, November 5) Fall 2012 (Saslow)

Lab 3: Quanser Hardware and Proportional Control

Kinematics, Dynamics, and Vibrations FE Review Session. Dr. David Herrin March 27, 2012

Lab 5a: Pole Placement for the Inverted Pendulum

DC Motor Position: System Modeling

Unit 7: Oscillations

Physics 41 HW Set 1 Chapter 15 Serway 8 th ( 7 th )

Plane Motion of Rigid Bodies: Forces and Accelerations

Chapter 14 Periodic Motion

ECEN 420 LINEAR CONTROL SYSTEMS. Lecture 6 Mathematical Representation of Physical Systems II 1/67

Oscillations. Oscillations and Simple Harmonic Motion

CHAPTER 12 OSCILLATORY MOTION

Coupled Drive Apparatus Modelling and Simulation

Mechatronics. MANE 4490 Fall 2002 Assignment # 1

Mechatronic System Case Study: Rotary Inverted Pendulum Dynamic System Investigation

Physics 2210 Homework 18 Spring 2015

Harmonic Oscillator. Mass-Spring Oscillator Resonance The Pendulum. Physics 109 Experiment Number 12

In-Class Problems 30-32: Moment of Inertia, Torque, and Pendulum: Solutions

Moment of Inertia Race

Real-Time Implementation of a LQR-Based Controller for the Stabilization of a Double Inverted Pendulum

Laboratory 11 Control Systems Laboratory ECE3557. State Feedback Controller for Position Control of a Flexible Joint

Final Examination Thursday May Please initial the statement below to show that you have read it

PHYSICS 221, FALL 2011 EXAM #2 SOLUTIONS WEDNESDAY, NOVEMBER 2, 2011

System Parameters and Frequency Response MAE 433 Spring 2012 Lab 2

Rotary Inverted Pendulum

Rotational Dynamics continued

FEEDBACK CONTROL SYSTEMS

AP Physics C: Rotation II. (Torque and Rotational Dynamics, Rolling Motion) Problems

Topic 1: Newtonian Mechanics Energy & Momentum

( ) Physics 201, Final Exam, Fall 2006 PRACTICE EXAMINATION Answer Key. The next three problems refer to the following situation:

16.07 Dynamics. Problem Set 10

1. Replace the given system of forces acting on a body as shown in figure 1 by a single force and couple acting at the point A.

Chapter 12. Recall that when a spring is stretched a distance x, it will pull back with a force given by: F = -kx

28. Pendulum phase portrait Draw the phase portrait for the pendulum (supported by an inextensible rod)

MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.

Investigation of a Ball Screw Feed Drive System Based on Dynamic Modeling for Motion Control

Rotary Motion Servo Plant: SRV02. Rotary Experiment #01: Modeling. SRV02 Modeling using QuaRC. Student Manual

Rotational Mechanics Part III Dynamics. Pre AP Physics

SRV02-Series Rotary Experiment # 1. Position Control. Student Handout

!T = 2# T = 2! " The velocity and acceleration of the object are found by taking the first and second derivative of the position:

Rigid bodies - general theory

CEE 271: Applied Mechanics II, Dynamics Lecture 25: Ch.17, Sec.4-5

Harmonic Oscillator. Outline. Oscillatory Motion or Simple Harmonic Motion. Oscillatory Motion or Simple Harmonic Motion

2.4 Harmonic Oscillator Models

Quanser NI-ELVIS Trainer (QNET) Series: QNET Experiment #02: DC Motor Position Control. DC Motor Control Trainer (DCMCT) Student Manual

Human Arm. 1 Purpose. 2 Theory. 2.1 Equation of Motion for a Rotating Rigid Body

Rotational motion problems

is acting on a body of mass m = 3.0 kg and changes its velocity from an initial

a) Find the equation of motion of the system and write it in matrix form.

Concept Question: Normal Force

Rotation. PHYS 101 Previous Exam Problems CHAPTER

Solution Only gravity is doing work. Since gravity is a conservative force mechanical energy is conserved:

CEE 271: Applied Mechanics II, Dynamics Lecture 27: Ch.18, Sec.1 5

Inverted Pendulum System

Positioning Servo Design Example

TOPIC E: OSCILLATIONS SPRING 2019

Phys 106 Practice Problems Common Quiz 1 Spring 2003

Appendix W. Dynamic Models. W.2 4 Complex Mechanical Systems. Translational and Rotational Systems W.2.1

Chapter 8 Rotational Motion

LAST TIME: Simple Pendulum:

2.4 Models of Oscillation

6. Find the net torque on the wheel in Figure about the axle through O if a = 10.0 cm and b = 25.0 cm.

UNIVERSITI TUN HUSSEIN ONN MALAYSIA FINAL EXAMINATION SEMESTER I SESSION 2009/2010

Final Examination Thursday May Please initial the statement below to show that you have read it

In the presence of viscous damping, a more generalized form of the Lagrange s equation of motion can be written as

SRV02-Series Rotary Experiment # 7. Rotary Inverted Pendulum. Student Handout

CHAPTER 10 ROTATION OF A RIGID OBJECT ABOUT A FIXED AXIS WEN-BIN JIAN ( 簡紋濱 ) DEPARTMENT OF ELECTROPHYSICS NATIONAL CHIAO TUNG UNIVERSITY

The basic principle to be used in mechanical systems to derive a mathematical model is Newton s law,

2.003 Engineering Dynamics Problem Set 4 (Solutions)

Textbook Reference: Wilson, Buffa, Lou: Chapter 8 Glencoe Physics: Chapter 8

AP Physics QUIZ Chapters 10

Quantitative Skills in AP Physics 1

CHAPTER 8: ROTATIONAL OF RIGID BODY PHYSICS. 1. Define Torque

EE Homework 3 Due Date: 03 / 30 / Spring 2015

ASEISMIC DESIGN OF TALL STRUCTURES USING VARIABLE FREQUENCY PENDULUM OSCILLATOR

The Damped Pendulum. Physics 211 Lab 3 3/18/2016

Chapter 14 Oscillations. Copyright 2009 Pearson Education, Inc.

MECH 3140 Final Project

Handout 6: Rotational motion and moment of inertia. Angular velocity and angular acceleration

KNIFE EDGE FLAT ROLLER

Uniform Circular Motion

Your Name: PHYSICS 101 MIDTERM. Please circle your section 1 9 am Galbiati 2 10 am Kwon 3 11 am McDonald 4 12:30 pm McDonald 5 12:30 pm Kwon

State Space Representation

Lectures Chapter 10 (Cutnell & Johnson, Physics 7 th edition)

In this chapter the energy and momentum methods will be added to the tools available for your study of the motion of rigid bodies.

Mechatronics Engineering. Li Wen

Chapter 8. Rotational Motion

The University of Melbourne Engineering Mechanics

Overview of motors and motion control

Manufacturing Equipment Control

Project Lab Report. Michael Hall. Hao Zhu. Neil Nevgi. Station 6. Ta: Yan Cui

1. [30] Y&F a) Assuming a small angle displacement θ max < 0.1 rad, the period is very nearly

DYNAMICS MOMENT OF INERTIA

Physics 207 Lecture 25. Lecture 25. HW11, Due Tuesday, May 6 th For Thursday, read through all of Chapter 18. Angular Momentum Exercise

PHYSICS LAB Experiment 9 Fall 2004 THE TORSION PENDULUM

Transcription:

PARAMETER IDENTIFICATION, MODELING, AND SIMULATION OF A CART AND PENDULUM Erin Bender Mechanical Engineering Erin.N.Bender@Rose-Hulman.edu ABSTRACT In this paper a freely rotating pendulum suspended from a cart that slides on two parallel rails is modeled. In order to create this model several system parameters had to e experimentally determined. These parameters include the rotational damping and coulom friction of the earings attaching the pendulum to the cart, as well as the linear damping and coulom friction of the linear earings which the cart slides on. The results from a simple experiment were examined to determine each parameter. For the rotational terms the pendulum, suspended from a stationary cart, is given an initial displacement. The system is then modeled and the measured displacement is compared to the prediction of the model. For the translational terms the cart was modeled as free to oscillate etween two springs in tension, the pendulum was omitted from this analysis. In each case, the simulations were performed using Dymola and Simulink computer packages and the difference etween the experiment and the model was minimized y varying the parameter to e identified. Values were otained for the rotational and linear damping, as well as the rotational and linear coulom friction, which caused the model to agree nicely with the experiment. Keywords: Modeling, Simulation, Cart and Pendulum, Simulink, Dymola INTRODUCTION For this project the cart and pendulum set-up in the Dynamic Systems and Controls La was utilized. The system itself is descried in further detail elow. The project goal is to create a model which accurately predicts oth the pendulum position and the cart position. Although a model of the system existed previous to this project, it had not een updated in quite some time. Therefore it was desirale to redetermine several system parameters, as they appear to have changed over time. These parameters were determined y conducting two simple experiments and comparing the results to the experiment. SYSTEM DESCRIPTION The system consists of a slender rod attached y way of two earings to a cart. The cart is mounted on four pillow lock linear earings, which slide along two parallel rails. The pendulum is free to swing elow the cart. If the pendulum is mounted aove the cart, the system is the conventional inverted pendulum system familiar in controls las everywhere. The input to the system is the voltage supplied to a DC motor. The motor then produces a torque, which is put through a series of gears and then transmitted to the

cart through a plastic chain. User input through a computer controls the input voltage. A system schematic can e seen in Fig. 1. Descriptors The following variales are used to descrie the ehavior of the system. θ displacement angle of the pendulum x displacement distance of the cart ω output velocity of the motor m ω output velocity of the rake motor Measured Parameters The following parameters were measured from the physical system. Tale 1: Measured System Parameters Parameter Value Description m c 4.609kg mass of the cart m 0.1719kg mass of the pendulum l p p g,1 0.86m length of the pendulum r 0.0164m radius of gear 1 t 0.00414m thickness of gear 1 g,1 r 0.05m radius of gear g, t 0.00419m thickness of gear g, r 0.0376m hu radius of hu t 0.0m hu thickness of hu r 0.0181m radius of gear 3 g,3 t 0.00945m thickness of gear 3 g,3

Π α Π α Π Figure 1: System Schematic with Descriptors and Parameters Identified

Calculated Parameters The system parameters given in Tale were calculated from the physical system using Eq. (1), (), and (3).The mass moment of inertia of the pendulum was calculated using the measured mass and length of the pendulum and Eq. (1). It was not possile to physically remove the gears from the system in order to weigh them. It was therefore necessary to estimate the mass of each gear from measurale system quantities. The radius and thickness of each gear was measured, these data can e seen in Tale 1. Gears 1 and were assumed to e made of steel, while gear 3 was assumed to e made of aluminum, the specific weight of each sustance is given elow. The approximate mass of each gear was then computed using Eq. (). Finally the mass moment of inertia of each gear could e computed using Eq. (3). The results of oth of these computations can e seen in Tale. Mass moment of inertia of a slender rod-taken aout the end point: 1 (1) I O = ml 3 Mass of a cylinder: m = γπr t () kg where γ = 7860 for steel m 3 kg and γ = 767.97 for aluminum 3 m Mass moment of inertia of a thin disk: 1 I mr G = (3) Tale : Calculated System Parameters Parameter Value Description I G, N m mass moment of inertia of the pendulum p 0.0438 rad sec m 0.075kg mass of gear 1 G,1 I G,1 6 N m mass moment of inertia of gear 1 3.698E rad sec m 0.0657kg mass of gear G, I G, 5 N m mass moment of inertia of gear.086e rad sec m 0.775kg mass of the hu hu I hu 4 N m mass moment of inertia of the hu 5.478E rad sec I sprocket 4 N m mass moment of inertia of the sprocket 5.687E rad sec

m 0.069kg mass of gear 3 G,3 I G,3 4.406E 6 N m mass moment of inertia of gear 3 rad sec Provided The following parameters were otained from the manufacturer s specifications we page [1]. Motor R, 0.739Ω armature resistance a m L, 45 µ H armature inductance a m J m c m K e, m K t, m 1.0E 4.094E 0.0178 0.170 N m rad sec 6 N m rad sec V RPM N m A moment of inertia viscous damping constant ack emf constant torque constant Brake Motor R, 1.10Ω armature resistance a L, 100 µ H armature inductance a J c K e, K t, N m 0.19 rad sec 7 N m 7.330E rad sec 0.0094 0.0883 V RPM m A N moment of inertia viscous damping constant ack emf constant for the motor used as a rake torque constant for the motor used as a rake

SYSTEM IDENTIFICATION Rotational Damping Pendulum Encoder Caliration Experimental Set-Up In order to determine the rotational damping of the earings that attach the pendulum to the cart, a simple experiment was performed. The cart was held stationary, the pendulum was given an initial displacement from the horizontal, an encoder was used to measure θ, and the data was acquired y a data acquisition system. A diagram of this experimental set-up can e seen in Fig.. Π Figure : Rotational Damping Experimental Set-Up Model Development Initially the pendulum was modeled assuming only rotational damping was present. For this system Eq. (4) was derived as the equation of motion. mgl (4) p J & θ + & rθ = sin( θ ) The est value for the damping will provide the smallest difference etween the experimental data and the theoretical Dymola simulation results. To find this value a cost function, defined y Eq. (5), was used. This cost function is the sumsquared error etween the experimental and theoretical data. J = θ θ (5) ( ) theoretical exp erimental The Dymola simulation was run in Simulink with several different values of r, and J was calculated each time. A plot of several iterations of this process can e seen in Fig. 3. The damping constant which produced the lowest error value is N m r = 0. 0375. rad s

0.4 sum squared error 0.39 0.38 0.37 0.36 0.35 0.034 0.035 0.036 0.037 0.038 0.039 0.04 0.041 0.04 damping coefficient Figure 3: Minimization of System Error for Rotational Damping After minimizing the error with only rotational damping, coulom friction is added to the model. For this more complex system, Eq. (6) was derived as the equation of motion. In order to accurately model the coulom friction, that is to make it always negative, the coulom friction constant was multiplied y the sign of the angular velocity. In doing this, if the angular velocity is negative, a negative sign will e added to the coulom friction term making it positive. However, if the angular velocity is positive, the coulom friction term will remain negative. & θ & mgl (6) p J + θ sin( θ ) c sign( & r = r θ ) The values of r and c r that minimize the error etween Eq. (6) and the N m experimental data are c r = 0 and r = 0. 0375. Thus, the pendulum is most rad s accurately modeled with rotational damping and no coulom friction. Simulation Settings The experimental data was taken y an encoder with a sample frequency of 100 Hz. In order to easily calculate the error etween the experimental data and the Simulink output it was desired that the Simulink model also run at a sample frequency of 100 Hz, that is a step size of 0.01 seconds. This was accomplished y making Simulink solve the model with a fixed time step size ODE solver, as opposed to a variale time step solver. For this particular simulation, a fourth order Runga-Kutta solver was used.

Simulation Results N m After running the model several times a value of r = 0. 0375 was rad s found to minimize the error. A plot of the Simulink output and the experimental data for the final value of the rotational damping constant can e seen in Figure. Linear Damping Figure 4: Simulink and Experimental Data Experimental Set-Up In order to determine the linear damping of the cart, a spring was hooked to either end of the cart. The other end of each spring was then hooked into a clamp which was rigidly attached to the frame of the system. The cart was then deflected an initial distance to one side and released, while an encoder was used to measure the position of the cart. It was not possile to measure the position of the cart directly, ut there was an encoder set-up to measure the output from a tachometer attached to the motor. For this reason the motor and the rake motor were left in the system, and the data from the tachometer was converted to give the position of the cart.. A diagram of this experimental set-up can e seen in Fig. 5.

Π α α Π Figure 5: Linear Damping Experimental Set-Up Spring Constant Determination After the experiment was finished each spring was hung from a rigid support and various weights were hung on the free end. The deflection of the spring in centimeters was measured for each weight used. These values were then plotted in MatLa and the polyfit and polyval commands were used to determine a linear approximation of the data. These approximations can e seen elow as Eq. (7) and (8). In each case the coefficient for the deflection term is the spring constant. Thus K1 = 1197. 3N m and K = 130. 1N m. F 1 = 1197.3x1 + 0.0014 (7) F = 130.1x 0.0001 (8) A plot of the experimental data and the linear approximation for each spring can e seen elow in Figures 6 and 7.

Figure 6: Determination of Spring Constant One Figure 7: Determination of Spring Constant Two Model Development Initially the cart was modeled assuming that the moments of inertia of the gears were not negligile, and that the moments of inertia provided y the manufacturer for the motors were correct. The springs connecting the cart to the frame were assumed to e operating in their linear regions, and each spring was initially deflected 0.095m. This yielded Eq. (9) as the equation of motion.

[ m + m ]& x + [ c + ] x& + K x + 0.095) K (0.095 x) + c sign( x& ) 0 c inertial where and c m inertial inertial inertial ( c = L 1 ( L = I g, 1 I g, (I g,3 + J m + J ) r = + r m 1 + c ) r + r1 r3 This simulation was run in Simulink and plotted against the experimental data, see Fig. 8. r r 1 3 (9) Figure 8: Initial Model for Linear Damping Terms Oviously Eq. (9) is not a very good model of the system. The most ovious reason for this discrepancy is that the moments of inertia for the motors are not correct. Another possiility is that the control system is acting in some way which is not understood at this time. A new model for the system was derived and can e seen in Eq. (10). This time the moments of inertia for the gears were assumed to e negligile, as they are very small and can e accounted for in the added inertial term. Also the coulom friction was assumed to e 10 N since that is force found in an informal experiment and it didn t produce a noticeale effect on the simulation output. A spring scale was attached to the cart and used to pull the cart at a constant velocity, as this was done the scale read approximately 10 N.

( m + m )& x + x& c inertial L + K1 ( x + 0.095) K (0.095 x) + 10 = 0 (10) where m inertial is an input eing solved for The est values for the damping and the additional mass of the system will provide the smallest difference etween the experimental data and the theoretical Dymola simulation data. To find this value a cost function was used again. This cost function is the sum-squared error etween the experimental data and theoretical results and can e seen in Eq. (5). First the linear damping term was changed while the inertial mass was held constant at 6.8. A plot of the various values for oth the linear damping and the error can e seen in Fig. 9. Figure 9: Minimization of System Error with Inertial Mass Held Constant Next the inertial mass term was changed while the linear damping was held at 51. As aove a plot of inertial mass and the system error can e seen in Fig. 10. Figure 10: Minimization of System Error with Linear Damping Held Constant

Simulation Settings The settings are the same as they were for the rotational damping simulation. Simulation Results After running the simulation several times final values of l N m = 48 for rad s the linear damping and m inertial = 6. 8kg for the added inertial mass of the system were found to minimize the error. A plot of the Simulink output and the experimental data for these values can e seen in Fig. 11. Figure 11: Final Model for Linear Damping Terms

SUMMARY OF IDENTIFIED PARAMETERS The following parameter values were experimentally determined. Tale 3: Experimentally Determined Parameters N m rotational damping of the pendulum earings 0.0375 rad s c r 0 coulom friction of the pendulum earings K 1 1197.3N m spring constant of spring 1 K 130.1N m spring constant of spring N m initial linear damping of the pendulum earings 48 rad s m 6.8kg inertial final inertial mass of the system N m final linear damping of the pendulum earings 51 rad s r l l CONCLUSIONS Values were otained for all of the parameters which were to e experimentally determined and can e seen in Tale 3 aove. The model for the rotational damping of pendulum earings matched the experimental data with no additional changes to the model. With the linear model, however, it was found that inertial mass needed to e added to the system in order for the model and the experiment to agree. After this additional mass was included in the model, the simulation and the experiment matched quite well. This indicates that further work needs to e done in identifying the parameters of the system and understanding the control system. FURTHER WORK Experimentally identify the parameters of the motors inertial mass armature resistance armature inductance viscous damping constant Construct and test a DAE model of the entire closed loop system controller in the loop the pendulum inverted Construct and train a neural net model ACKNOWLEDGEMENTS Ben Howe for his help numerous times in setting up and running experiments. REFERENCES [1] www.motionvillage.com

APPENDIX A: SIMULINK MODEL AND ASSOCIATED DYMOLA CODE Rotational Damping Model:.03 [r] tv ar 1 c[r] c Dym olablock Scope theta T o Workspace egin RotaDamp.mo class RotaDamp parameter Real m=0.1791; parameter Real L=0.86; parameter Real g=9.81; parameter Real I=0.044; input Real ; input Real c; Real theta; Real f; output Real tvar; equation tvar = theta; der(theta) = f; I*der(f) + *f + m*g*l/*sin(theta) + c*f = 0; end RotaDamp end RotaDamp.mo

Initial Linear Damping Model: 35 L linear dam ping x xout 10 coulom friction c L T o Workspace egin LinearDamp.mo class LinearDamp parameter Real mc=4.609; parameter Real Ig1=3.698E-6; parameter Real Ig=5.687E-4; parameter Real Ig3=4.406E-6; parameter Real J=0.19; parameter Real Jm=1.E-4; parameter Real K1=1197.3; parameter Real K=130.1; parameter Real c=7.330e-7; parameter Real cm=.094e-6; parameter Real r1=0.0164; parameter Real r=0.05; parameter Real r3=0.0181; Dym ol abl ock Scope Real tempx(start=0.1146); Real TotalMass; Real TotalDamp; Real coulom; Real f; input Real L; input Real cl; output Real x(start=0.1146); equation TotalMass = mc + *(Ig1 + Ig)/r1 + (*Ig3 + Jm + J)*r/(r1*r3); TotalDamp = (cm + c)*r/(r1*r3) + L; tempx = x; cou = cl*sign(f); f = der(tempx); TotalMass*der(f) + TotalDamp*f + K1*(x + 0.095) - K*(0.095 - x) + cou = 0; end LinearDampend LinearDamp.mo

Modified Linear Damping Model: 6.8 m inert inertial m ass x xout 48 linear dam ping L T o Workspace egin LinearDampMod.mo model LinearDampMod parameter Real mc=4.609; parameter Real K1=1197.3; parameter Real K=130.1; Dym olablock Scope Real tempx; Real f; input Real minert; input Real L; output Real x; equation tempx = x; f = der(tempx); (mc + minert)*der(f) + L*f + K1*(x + 0.095) - K*(0.095 - x) + 10 = 0; end LinearDampMod end LinearDampMod.mo

APPENDIX B: MATLAB CODE Rotational Damping Model: egin RotaDampCode.m % Import the output of the Simulink model (theta) and the time vector (tout) from the workspace % Plot the Simulink output vs. experimental data figure plot(tangle,angle,tout,theta,':') axis([0,5,-0.4,0.3]) xlael('time (sec.)') ylael('theta (rad.)') grid legend('experimental Data','Theoretical Data') % Calculate the squared error and plot it for several values of r % Output the sum squared error for easy reference Err = (angle - theta).^; J = sum(err) % Vectors of the damping coefficient input to the simulink model % and the output sum squared error input = [0.01 0.0 0.03 0.035 0.037 0.0373 0.0375 0.0377 0.038 0.04 0.041 0.04 0.05 0.06 0.07 0.1 0.15 0.]; outputj = [4.619 1.546 0.515 0.3766 0.363 0.368 0.368 0.369 0.3634 0.3758 0.387 0.4018 0.6017 0.9673 1.3741.549 3.9557 4.96]; figure plot(input,outputj,'*') axis([0.034,0.043,0.35,0.41]) xlael('damping coefficient') ylael('sum squared error') end RotaDampCode.m Linear Damping Model: egin SpringConstants.m % Calculation of Spring Constants % the masses are in ls the force is in Newtons mass = [0 7.48 10.005 1.45 16.45]; force = mass.*0.454.*9.81; % Spring 1 Length1 = [0.11 0.135 0.145 0.155 0.17]; Deflec1 = Length1-0.11;

[P1] = polyfit(deflec1, force, 1) y1 = polyval(p1, Deflec1); % plot the experimental data points and the linear approximation % for the deflection of spring 1 figure plot(deflec1,force,'*',deflec1,y1) grid xlael('deflection (m)') ylael('force (N)') axis([0,0.06,0,80]) % Spring Length = [0.15 0.15 0.16 0.1675 0.18]; Deflec = Length-0.15; [P] = polyfit(deflec, force, 1) y = polyval(p, Deflec); % plot the experimental data points and the linear approximation % for the deflection of spring figure plot(deflec,force,'*',deflec,y) grid xlael('deflection (m)') ylael('force (N)') axis([0,0.06,0,80]) end SpringConstants.m eginlineardampcode.m pos = exp.*0.054; time = [0:0.01:1.08]; % Import the output of the Simulink model (xout) and the time vector (tout) from % the workspace plot the Simulink output vs. experimental data plot(time,pos,'.',tout,xout) xlael('time (sec.)') ylael('position (m.)') grid legend('experimental Data','Simulation Results') % Calculate the squared error and plot it % Output the sum squared error for easy reference J = (pos - xout).^; sum(j) endlinear DampCode.m