You are on page 1of 17

Mechanics with Matlab

April 2001

The MechMat project has been carried out with the support of the Commission of the European Communities under the Leonardo da Vinci programme (contract number CZ/98/1/82500/PI/I.1.1.b/FPI).

2 Prof. V. Stejskal Project coordinator Czech Technical University Karlovo nam. 13 CZ-12135 Praha Czech Republic stejskal@vc.cvut.cz Prof. P. Dehombreux Facult Polytechnique de Mons Belgium pierre.dehombreux@fpms.ac.be Prof. A. Eiber University of Stuttgart Germany ae@mechb.uni-stuttgart.de Prof. R. Gupta Uppsala University Sweden ram.gupta@material.uu.se Prof. M. Okhroulik Czech Academy of Sciences Czech Republic ok@it.cas.cz

Contents
1 The MechMat Project 1.1 Objectives . . . . . . . . . . . . . . . . . . . . . . . . 1.2 How to use this document . . . . . . . . . . . . . . . . 1.3 Modelling . . . . . . . . . . . . . . . . . . . . . . . . 1.4 M ATLAB basics . . . . . . . . . . . . . . . . . . . . . 1.4.1 Basic calculations . . . . . . . . . . . . . . . . 1.4.2 Solving linear algebra problems with M ATLAB 1.4.3 Plotting data in M ATLAB . . . . . . . . . . . 1.4.4 Other useful M ATLAB commands . . . . . . . 2 4 . 4 . 5 . 6 . 9 . 9 . 13 . 14 . 14 16 16 16 16 17 17 18 18 22 23 23 24 25 29 31 32 32 32 33 35

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

Kinematics 2.1 Basic Concepts . . . . . . . . . . . . . . . . . . . . . . . . 2.2 Kinematics of a particle. Rectilinear and curvilinear motion . 2.2.1 Position vector. Velocity vector. Acceleration vector 2.2.2 Average and instantaneous velocities . . . . . . . . 2.2.3 Average and instantaneous acceleration . . . . . . . 2.2.4 Absolute frame . . . . . . . . . . . . . . . . . . . . 2.2.5 Tangential and normal coordinates . . . . . . . . . . 2.2.6 Rotation around a xed point in a plane . . . . . . . 2.3 Kinematics of a rigid body . . . . . . . . . . . . . . . . . . 2.3.1 Translation . . . . . . . . . . . . . . . . . . . . . . 2.3.2 Rotation about a xed axis . . . . . . . . . . . . . . 2.3.3 Particular case: Motion in plane . . . . . . . . . . . 2.3.4 General motion in space . . . . . . . . . . . . . . . 2.3.5 Rolling without slipping . . . . . . . . . . . . . . . 2.4 Kinematics of systems of rigid bodies . . . . . . . . . . . . 2.4.1 Mechanism . . . . . . . . . . . . . . . . . . . . . . 2.4.2 Degrees of freedom . . . . . . . . . . . . . . . . . . 2.4.3 Lower pairs and higher pairs . . . . . . . . . . . . . 2.4.4 Kinematics exercises . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . .

CONTENTS
3 Statics 3.1 Basic Concepts . . . . . . . . . . . . . . . . 3.1.1 Force . . . . . . . . . . . . . . . . . 3.1.2 Moment of a force about a point . . . 3.2 Moment of a force about an axis . . . . . . 3.2.1 Couples of forces . . . . . . . . . . . 3.2.2 Principle of transmissibility . . . . . 3.2.3 Force systems . . . . . . . . . . . . . 3.2.4 Equivalence of two systems of forces 3.2.5 Equilibrium of force systems . . . . . 3.3 Equilibrium of a particle . . . . . . . . . . . 3.4 Equilibrium of a rigid body in a plane . . . . 3.5 Equilibrium of a rigid body in space . . . . . 3.6 Systems of rigid bodies . . . . . . . . . . . . 3.7 Trusses . . . . . . . . . . . . . . . . . . . . 3.8 Bodies and systems of bodies with friction . . 3.8.1 Journal bearing . . . . . . . . . . . . 3.8.2 Thrust bearing . . . . . . . . . . . . 3.8.3 Rolling resistance . . . . . . . . . . . 3.8.4 Belt friction . . . . . . . . . . . . . . 3.9 Centre of gravity . . . . . . . . . . . . . . . 3.10 Internal forces in a body . . . . . . . . . . . 3.11 Work and potential energy . . . . . . . . . . 3.12 Principle of virtual work . . . . . . . . . . . 3.13 Solutions of exercises . . . . . . . . . . . . .

2 61 61 61 63 65 71 72 72 73 74 76 83 88 93 100 104 105 105 106 106 112 116 121 128 132 190 191 191 194 196 197 197 199 204 204 212 214 232 232

. . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . .

Dynamics 4.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.1.1 Issues of applied dynamics . . . . . . . . . . . . . . . . . . 4.1.2 Modelling of Mechanical Systems . . . . . . . . . . . . . . 4.2 Mechanical Modelling . . . . . . . . . . . . . . . . . . . . . . . . 4.2.1 Elements of Multibody Systems . . . . . . . . . . . . . . . 4.2.2 System forces . . . . . . . . . . . . . . . . . . . . . . . . . 4.2.3 Kinematical constraints . . . . . . . . . . . . . . . . . . . . 4.3 Mathematical modelling . . . . . . . . . . . . . . . . . . . . . . . 4.3.1 Introduction to mathematical modelling . . . . . . . . . . . 4.3.2 Mathematical models and procedures . . . . . . . . . . . . 4.3.3 Formulation of governing equations of mechanical systems . 4.4 Application of Computational Procedures in Dynamic Analysis (draft version of the chapter) . . . . . . . . . . . . . . . . . . . . . . . . 4.4.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . .

CONTENTS
4.4.2 4.4.3 5

3 Dynamics of robot . . . . . . . . . . . . . . . . . . . . . . 245 Dynamics of slider-crank mechanism . . . . . . . . . . . . 269

Vibrations 301 5.1 Introduction to vibration . . . . . . . . . . . . . . . . . . . . . . . 301 5.2 Harmonic and periodic motions . . . . . . . . . . . . . . . . . . . . 302 5.3 Phase and group velocities . . . . . . . . . . . . . . . . . . . . . . 310 5.4 Fourier series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315 5.5 Fourier integral . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321 5.6 Discrete Fourier series . . . . . . . . . . . . . . . . . . . . . . . . 329 5.7 Deriving governing equations . . . . . . . . . . . . . . . . . . . . . 332 5.8 Numerical methods . . . . . . . . . . . . . . . . . . . . . . . . . . 332 5.8.1 Numerical methods for steady state vibration problems . . . . . . . . . . . . . . . . . . . . . . . . . . . 332 5.8.2 Numerical methods for transient problems . . . . . . . . . . 337 5.9 Vibration with 1 DOF . . . . . . . . . . . . . . . . . . . . . . . . . 345 5.9.1 Undamped free linear vibration of a one-degree-of-freedom system . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345 5.9.2 Undamped forced linear vibration of a one-degree-of-freedom system . . . . . . . . . . . . . . . 348 5.9.3 Damped linear vibration of a one-degree-of-freedom system with a harmonic excitation force . . . . . . . . . . . . 351 5.9.4 Overdamped, critically damped and underdamped linear vibrations of a one-degree-of-freedom system . . . . . . . . . 357 5.9.5 A vibrating system attached to a moving support . . . . . . 361 5.9.6 Behaviour of a one-degree-of-freedom linear system at resonance . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365 5.9.7 Vibration with Coulomb friction . . . . . . . . . . . . . . . 369 5.10 Systems with 2 DOF . . . . . . . . . . . . . . . . . . . . . . . . . 373 5.10.1 Undamped free and forced vibrations of a two-degrees-offreedom linear system . . . . . . . . . . . . . . . . . . . . 373 5.10.2 Comparison of analytical and numerical approaches to the solution of the transient response of a two-degrees-of-freedom linear system . . . . . . . . . . . . . . . . . . . . . . . . . 386 5.11 Systems with DOF . . . . . . . . . . . . . . . . . . . . . . . . . 394 5.11.1 Vibration of a linear system with degrees of freedom . . . 394 5.12 Continuous systems and their discretizations . . . . . . . . . . . . . 401 5.12.1 Bars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 401 5.12.2 Beams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 462

Chapter 1 The MechMat Project


1.1 Objectives
Although the basic concepts and laws of mechanics are known for centuries, radical changes occurred in techniques of application of these concepts in technical practice during the last decades. These new, up-to-date approaches, allowing to solve complicated technical problems with strong non-linearities, are efciently implemented on powerful computer platforms in forms of widely available commercial software packages. Both HW and SW resources are easily accessible at universities as well as in industrial sites. These changes signicantly inuence the demands of employers on employees. Tough competition calls for designers who are able to use computer tools extensively and efciently for securing the production and frequent modication of cheap and reliable products able to survive on the market. Many engineers on the labour market, however, have nished their studies in times when computers were not so frequent and methods of computational mechanics were virtually unknown and thus were not covered by their curricula. This, together with a natural process of forgettery, results in insufciency of skills in training of basic principles of mechanics in engineering community. The profound idea of liberation of designers from routine and cumbersome computations leading to their creativity can be hardly accomplished under the present unfavourable conditions. The presented electronic learning tool (ELT) is a response to the fact that the increasing availability of computers in engineering community is not always fully accompanied by proper knowledge of numerical and programming techniques required to employ efciently the principles of mechanics. These, in turn, are needed for nding the sought-after results concerning the response of a mechanical system to external loading. The presented ELT is not a textbook in a traditional sense of the word. Its main concept is based on new methodology of presentation called "learning by action" 4

CHAPTER 1. THE MECHMAT PROJECT

which means that its user (reader, learner) is expected to learn by working out numerous case studies based on real problems of technical practice by himself/herself. The modern personal computers are fully suited to the purpose. The learner has an immediate access to reviews of basic principles and to the high-performance numeric computation and visualisation software at the same time. Moreover, he/she is supplied by correct numerical solutions of the numerous problem by means of simple computer procedures. The ELT is based on very common hardware. Any PC or Unix machine connected to the internet will allow for downloading the text and computer programs. The local Matlab installation then will permit running and modifying the workedout examples. The Matlab version 5.3 was used. Matlab was used for its wide spread availability and for its ability to deal efciently with matrix algebra mathematics. The main aim of the proposed ELT is to increase the horizons of young people in initial training and to help designers in practice in their lifelong training to master the basic principles of computational mechanics and their application to the practical engineering problems. This will facilitate the starts of their professional careers and will improve their position on the labour market. The specic objective of the ELT is to improve the knowledge and skills level of the mechanical and civil engineering university students and practising engineers in one of the most important basic subject of engineering which is the science of mechanics. This knowledge and skills can be used in nearly all branches of industry. The international co-operation in the preparation of the project secures that the choice of practical problems to solve meets the demands of numerous engineers. The common experience of university teachers of mechanics from different European countries contributes to the European level of knowledge in this particular eld. The following impact on training is expected:

improvement of the training level of initial training improvement of the ability of students to solve challenging problems themselves improvement of the students ability to use a computer as a tool for solution of their everyday problems.

1.2 How to use this document


It has been said that this document is not a textbook in the traditional sense at all. It is designed to supplement standard texts and to assist students of engineering

CHAPTER 1. THE MECHMAT PROJECT

science to get prociency in engineering mechanics which is very often claimed to be very difcult subject. The autors are convicted that numerous solved problems is the best way for belief that student knows the principles and he is able to apply them when solving problems taken from technical practice. This, of course, leads to self-condence. The material presented here corresponds to standard introductory mechanics courses but does not match any particular textbook. So any standard textbook of mechanics (see references) can be used. Each chapter, however, begins with definitions, statements, principles, and theorems without pretence to be complete. A glossary of common terms was included at the end of the text for students convenience. One of the main aims of the text is not to nish solution of problems by writting down equations of equilibrium, equations of motion or kinematic equations without solving them. At the end of engineering solution should stand a number. Very often the numerical result proofs validity of the solution. But numerous of practical problems are not so simple to allow for analytical solution. So a tool for numerical computation is needed. The autors select M ATLAB for the purpose. The reason is its versatility, easy use, and good graphical capabilities. Last but not least M ATLAB is in common use within nearly all universities. The text is designed for students who study or have studied mechanics to help them to master the subject. The standard use is to study material displayed and to try solve examples presented by oneself. In case of difculties the solution can be consult. There are M ATLAB m-les ready and by playing with constants and modifying programs student is able to discover the base of the problem. Using Windows capabilities it is convenient to open a window of text and another window for M ATLAB simultaneously. Commnets in m-les can be very helpful. The autors hope that solved problems help the students to illustrate the theory, present methods of solution and enable them to apply the basic principles of mechanics correctly and condently.

1.3 Modelling
The phenomena of nature are inherently complex and it is impossible to consider their every detail when trying to describe, formulate and predict their future behaviour or occurrence. Always certain simplications have to be accepted. The idea behind modelling is to neglect what seems to have a negligible or small inuence on what is to be grasped. Accepting simplifying assumptions, however, leads to limited validity of models. Engineering modelling is well dened within the scope of Newtonian physics that admits the notion of inertial frame of reference and the notion of absolute time

CHAPTER 1. THE MECHMAT PROJECT

independent of space. The Newtonian description is unchanged under a Galileo transformation which is a mathematical device relating a single phenomenon recorded by two observers whose frame of reference differ by virtue of their travelling at different uniform velocities. According to Newtons concept, while the position of two observers differ by virtue of their relative motion, both have an identical perception of time, which does not depend on the frame of their reference. Newtonian mechanics provides a vital tool, which still perfectly works in all manners of ways from the motion of billiard balls or galaxy formation. The Newtonian concept is deterministic. If positions, velocities and masses of various bodies are given at one time, then their positions, velocities and accelerations are mathematically determined for all later times. And for earlier as well. Mechanics is the branch of physics concerned with the analysis of behaviour of objects under the action of forces. Historically the subject dealt with rigid bodies only, since then it is extended and applied to problems of solid and uid continuum. In the latter scope it is sometimes called classical mechanics as a contrast to quantum mechanics. Continuum mechanics is concerned with formulation of equations describing the motion and mechanical and thermal behavior of matter and with the solution of these equations for prescribed initial and boundary conditions. Usually solid and uid continua are being distinguished and treated by somewhat different approaches. In the text we will devote our attention to solid mechanics. Very often mechanical structure can be modelled by a systems having nite number of degrees of freedom. In such a case we talk about discrete mechanical models. Bodies we are dealing with could be considered rigid or deformable. Rigid body, within the scope of solid continuum, is a model characterized by innite stiffness of matter. By denition a rigid body perfectly resists deformation due to the action of forces, as such it cannot be deformed. Deformable body is a body (mechanical system, structure) which deforms under the action of an applied force. Within the scope of solid continuum it is a model characterized by a proper constitutive relation between force and displacement, and stress and strain. Very often we simplify the modelling process by accepting assumptions of linearity. If all basic components of a system behave linearly, the response of the system is known as linear. This means that there is a linear relation between displacements and forces, velocities and damping forces, etc. Linear systems are based on assumptions of small strains and small displacements. Equations of equilibrium are written for an undeformed conguration of the structure and the principle of superposition can safely be used. The resulting system of differential equations is of linear nature as well. On the other hand if any of the basic components behave nonlinearly, the system is nonlinear.

CHAPTER 1. THE MECHMAT PROJECT

The modelling process in engineering usually proceeds in following steps. Setting the mechanical model. The most engineering systems are complex, it is impossible to consider every detail of them and so certain simplications have to be accepted. Model can be viewed as an idealization of a real or conceived machine or structure obtained by accepting certain simplifying assumptions. We accept the validity of Newtonian mechanics as far as the inertia frames of references are concerned and thus do not deal with principles of relativity. We accept the assumptions upon which the continuum mechanics is based, i.e., that the matter, when divided into innitesimal elements, has always the same mechanical properties that are independent of their size - by other words we do not deal with molecular and atomic structure of the matter. Considered bodies or structures could be smooth or rough, material properties could be taken as homogeneous or non-homogeneous, isotropic or unisotropic, linear or non-linear, constraints and loading could be simplied, etc. Very often it is expedient to model a part of the structure under consideration as fully rigid and to neglect inertia effects of exible parts. All together, it is a tricky procedure and what is adequate for one purpose may not be adequate for other purposes. Derivation of governing equations. Once the mechanical model is established we use principles of mechanics and derive the equations of motion or the equations of equilibrium. Many approaches are commonly used - among them are free body diagrams using the balance of forces including the inertial ones, energy balance principles and others. Solution of governing equations. Depending on the nature of the problem we can use analytical methods (Fourier series, integral transforms, etc) or numerical methods (boundary element method, nite element method, etc.) Interpretation of results. Results must be carefully interpreted with a clear view of physical signicance and compliance with assumed simplications. All the mentioned steps depend essentially on the experience and judgement of the person analyzing the problem. In this text the modelling in mechanics is treated by distinct chapters devoted to statics, kinematics, dynamics and vibration, with a special emphasis to numerical treatment of numerous examples and on the discussion of results. Statics is branch of mechanics dealing with analysis of behaviour (usually in terms of displacements, strains, stresses and forces) of bodies (mechanical systems, structures) while neglecting inertia effects. It is based on equilibrium conditions, time plays no role in the analysis. Kinematics is concerned with study of motion of bodies (mechanical systems, structures) without regard to the forces causing the motion. Dynamics is a branch of mechanics where due emphasis is paid to inertial effects as opposed to statics where such effects are ignored. Vibration is a subset of dynamics of rigid and deformable bodies dedicated to

CHAPTER 1. THE MECHMAT PROJECT

study of oscillatory motions. It is the Matlab programming language which treats the worked-out examples in the above-mentioned chapters. Matlab is a tool that efciently deals with matrix algebra mathematics and has a very high level of programming primitives. As such it is almost predestined to be a good teaching tool for learning how to implement mechanical and numerical principles needed for the solution of a wide class of mechanical problems in engineering.

1.4

M ATLAB basics

M ATLAB is a commercial interpreter devoted to numerical matrix algebra computing and graphical representation. This section summarizes some basic commands showing how the exercises can be solved using the software. The reader is assumed to already have some knowledge of M ATLAB . A prior reading of the Getting started with M ATLAB handbook ([2]) is therefore recommended.

1.4.1 Basic calculations


One can perform the following elementary operations simply introducing the corresponding commands after the > sign. The complex numbers can be used without restriction:
> 2*4+2 ans = 10 > (2+sqrt(-1))^2 ans = 3.0000 + 4.0000i + * - /

In M ATLAB , the variables do not need a prior declaration. Their names may be of any length, using most most printable characters and are case-sensitive. If the semicolon terminates a command, no output is produced in the active M ATLAB window.
> rayon = 1e-1; > surface = pi * rayon * rayon surface = 0.0314

variables

Matrices are dened using square brackets [ and ]. In each row, the elements are distinguished using commas , or spaces and the rows are distinguished using semicolons ;. To address matrix elements, one has to specify them in parentheses ( and )by means indices.

vectors matrices

CHAPTER 1. THE MECHMAT PROJECT


> MAT = [ 1, 2, 3; 4, 5, 6; 7, 8, 10] MAT = 1 2 3 4 5 6 7 8 10 > MAT(3,3) = 17 MAT = 1 2 3 4 5 6 7 8 17 > vec = [10; 0; 1000] vec = 10 0 1000

10

The vectors can be seen as column-vectors (-by-1 matrices) by default or as row-vectors (1-by- matrices). The colon : can either be used to dene ranges or, alternatively, to generate a series of numbers. In parentheses, the colon : refers to all elements included in a row (column) of a matrix.
> t = 1:5 t = 1 2 3 > lin = MAT(1,:) lin = 1 2 > col = MAT(:,1) col = 1 4 7 > 1:0.3:2 ans = 1 1.3000

1.6000

1.9000

Many problems may arise from a possible confusion between row-vectors and column-vectors. With M ATLAB , it is quite natural to generate row-column vectors (t=1:5). A straight method to be sure that a vector is of a column is to use the : operator:
> tt = t(:) tt = 1 2 3

CHAPTER 1. THE MECHMAT PROJECT


A A. conj(A)

11

conjugated transpose (hermitian) of unconjugated transpose of conjugate of Table 1.1: Conjugated and transposed matrices

4 5

As for scalars, vectorial or matricial operations are computed quite easily:


> sum = vec - 2*col sum = 8 -8 986 > lin * col ans = 30 > product = MAT * vec product = 3010 6040 17070

Certain operations between vectors and matrices can be computed element-byelement if the related operator (product * for example) is preceded by a dot .. .
> MAT.*MAT ans = 1 4 16 25 49 64

element-byelement operations

9 36 289 Transpose Conjugate

One can transpose a real matrix (or vector) using the apostrophe . As shown in Table 1.1, if the matrix (or vector) is complex, one has to use the dot-apostrophe operator . to simply transpose it; in that case, the sole apostrophe provides the conjugated transpose. It is quite easy to call and work with a function but it needs the prior denition of a text le which name is identical to the name of the function and which extension is .m. Any text editor can be used for this purpose. For example, the le myfunc.m will include the following operations:
function [result] = myfunc (x) x3 = x*x*x; result = x3 + sin(x) - 2;

CHAPTER 1. THE MECHMAT PROJECT

12

The functions dene within themselves local variables that can not be reached outside this context. The local variables do not exist outside the scope of their denition. Any function can be directly used from the directory wherein it has been saved (use the pathtool command to browse, dene or edit the current path).
> myfunc(1,-2) ans = -2.1585 > x3 x3 = Result is undefined

A function denes inputs and outputs that may vary in number and type (real, scalar, matrix, other function, ...). The logical variables are either 1 (true) or 0 (false). One can carry out comparisons between scalars using the following operators: >, >=, <, <=, == (equality), ~= (non equality). The logical and and or operations are dened by the & and | operators, respectively. M ATLAB supports test structures like :
x=input(Value); if x > 5 x greater than 5 else if x == 5 x equals 5 else x is less than 5 end end

logical operations

if then else

M ATLAB supports iterative structures like :

for while

x = 1:5 for i = 2:4 x.^i end % Comment: gives second, third and fourth powers for x evolving from 1 to 5 i=2; while i<5 x.^i i=i+1; end

CHAPTER 1. THE MECHMAT PROJECT

13

1.4.2 Solving linear algebra problems with M ATLAB


The solution of a classical linear system of equations can be easily obtained using the \ operator that should not be confused with the / division operator.
> x = MAT \ vector x = 993.33 -2006.7 1010

Linear systems

The eigenvalue problem is solved using the function eig(A,B) that produces two outputs: val for the eigenvalues and vec, for the eigenvectors :

Eigenvalues

> [vec,val] = eig (A,B);

As long as the eigenvalues are not sorted by the eig function, one has to use the sort function to do so, if necessary. A polynomial coefcients a given argument.

is dened by the row vector of its . The polyval function evaluates this polynomial for

Polynomial

> pol=[1,2,3,4] pol = 1 2 3 > polyval(pol,-1) ans = 2

The roots of a polynomial are computed using the roots function that takes the coefcients of that polynomial as input. One can therefore nd the roots of computing:
> pol=[1,2,3,4] pol = 1 2 > roots(pol) ans = -1.6506+ -0.1747+ -0.1747-

Polynomial roots

0.0000j 1.5469j 1.5469j polynomial regression

If one wants to t a set of values in a least-square sense, the polyfit function can be used to determine the coefcients of that optimal polynomial. For example, to establish the best straight line through the coordinates (1,10), (3,18) and (10,37), one has to compute:

CHAPTER 1. THE MECHMAT PROJECT


> x=[1 3 10]; > y=[10 18 37]; > polyfit(x,y,1) ans = 2.92537 8.01493

14

The line is therefore described by the equation . To nd the zeros of a nonlinear function, the nonstandard rroots function can be used :
> racines=rroots(myfunc,-1,10,100,1e-6) > racines = 1.0434

zero of a function

The rroots function works with the following input arguments: the name of the studied function, the lower and upper bounds for the zeros to be determined, the number of sub-intervals for the bisection algorithm to be applied and the tolerance related to the function residue(see the rroots.m le for details). The numerical integration of the equations of motion

and stiffness matrices, and submitted to the generalized forces can be performed using the newmark and defphy functions. See mckf*.m les for examples.

of a mechanical system dened through its mass , damping

(1.1)

Newmark integration

1.4.3 Plotting data in M ATLAB


plot

M ATLAB provides a wide library of visualization functions to work with line and surface plots, histograms, 3D objects with shading and animation. One can refer to [1] for a detailed description of the available features. We recall that the plot(x,y) command produces a classical vs. graph. An example is provided here under. The result is shown in Figure 1.1
x=(-5:0.1:5); plot(x,sin(x)./(x.*x+1)); xlabel (X axis) ylabel (Y axis) grid on title (A plot with MATLAB)

1.4.4 Other useful M ATLAB commands


M ATLAB commands who and whos list the existing variables. The clear command clears all variables. close all closes all the active gure windows.
who whos clear

BIBLIOGRAPHY
A plot with MATLAB 0.5

15

0.4

0.3

0.2

0.1 Y axis

0.1

0.2

0.3

0.4

0.5 5

0 X axis

Figure 1.1: Graph of .

Bibliography
[1] Using MATLAB Graphics. The MathWorks, Natick, MA, USA, 1996. [2] Getting Started with MATLAB. The MathWorks, Natick, MA, USA, 1997. [3] Irving H. Shames. Engineering Mechanics. Statics and Dynamics. Prentice Hall, Upper Saddle River, New Jersey, USA, 1996.

You might also like