1 / 11

Laboratory 2

Laboratory 2. LABORATORY OBJECTIVES. This lab work is intended to give the students more insights on the Matlab environment and how to work more efficiently with the commands window. The work is organized in two parts :

Download Presentation

Laboratory 2

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Laboratory 2

  2. LABORATORY OBJECTIVES • This lab work is intended to give the students more insights on the Matlab environment and how to work more efficiently with the commands window. • The work is organized in two parts : • Part 1 : guided work, where the students can work through the examples or procedures seen during the lectures • Part 2 : graded tasks through which the students demonstrate ability to apply what they learned independently.

  3. PART 1 : GUIDED TASKS A. Example • solving a quadratic equation using Matlab as a calculator • Imagine that an engineering problem led to the following second degree polynomial : 3x2 – x +2 =0 • Answer : • Compute descriminant : d=b2 – 4ac • If d=0  x1=x2=-b/2a • If d>0  x1,2=(-bd)/2a • If d<0  x1,2=(-bid)/2a (complexe numbers)

  4. Using the commands window, enter the following commands : • First use assignment statements to define the coefficients a, b, and c • >> a=…… ; • >> b=……; • >> c=……;

  5. Next, compute the descriminant (don’t use the semi-column ; to display the value of d !) : • >> d=…………. • d = • …………

  6. Then, compute the solutions : • >> x1= ……………………… • >> x2=………………………

  7. Note that in this example you have used Matlab as a calculator; Be informed that Matlab can solve this in a much simpler manner by the use of the function “roots” which will be studied later in the semester.

  8. Part 1 B. Working efficiently with the commands window

  9. Type “whos” to display the list of all defined variables • Clear the coefficients a, b, and c • See what happens when you type the following • >> a or >> b or >> c or >> d • Next type >> clear  This should result in deleting all variables ! • Finally, enter >> clc to clear the screen display

  10. Part 2 (Graded Tasks) 1. MatlabMathematic Built-in functions

  11. Part 2 (Graded Tasks) • 2. Common Error

More Related