Copyright © 2005. The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Introduction to MATLAB 7 for Engineers William J. Palm.

Slides:



Advertisements
Similar presentations
Welcome to EGR 106 Foundations of Engineering II Course information Today’s specific topics: – Computation and algorithms – M ATLAB Basics Demonstrations.
Advertisements

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. A Concise Introduction to MATLAB ® William J. Palm III.
Lecture 6 MATLAB functions Basics of Built-in Functions, Help Feature, Elementary Functions (e.g., Polynomials, Trigonometric Functions), Data Analysis,
Introduction to MATLAB 7
Introduction to MATLAB 7 for Engineers
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Introduction to MATLAB 7 for Engineers William J. Palm.
5.5 Solving Trigonometric Equations Example 1 A) Is a solution to ? B) Is a solution to cos x = sin 2x ?
Rev.S08 MAC 1114 Module 2 Acute Angles and Right Triangles.
Introduction to Trigonometry
Trigonometry 2 Aims Solve oblique triangles using sin & cos laws Objectives Calculate angles and lengths of oblique triangles. Calculate angles and lengths.
Warm Up for Section 1.2 Simplify: (1). (2). (3). There are 10 boys and 12 girls in a Math 2 class. Write the ratio of the number of girls to the number.
Introduction to MATLAB ENGR 1187 MATLAB 1. Programming In The Real World Programming is a powerful tool for solving problems in every day industry settings.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Introduction to MATLAB 7 for Engineers William J. Palm.
ENGR-25_MATLAB_AppMath_ProbSolve.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed.
Introduction to MATLAB for Engineers, Third Edition William J. Palm III Chapter 8 Linear Algebraic Equations PowerPoint to accompany Copyright © 2010.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. A Concise Introduction to MATLAB ® William J. Palm III.
MATLAB Tutorials Session I Introduction to MATLAB Rajeev Madazhy Dept of Mechanical Engineering LSU.
Copyright © Cengage Learning. All rights reserved. Trigonometric Functions: Right Triangle Approach.
1 Trigonometry Basic Calculations of Angles and Sides of Right Triangles.
Basic Trigonometry Review for Engineers PLUS! Solving systems of equations 5-Oct-15.
Copyright © 2005 Pearson Education, Inc.. Chapter 2 Acute Angles and Right Triangles.
Copyright © 2005 Pearson Education, Inc.. Chapter 2 Acute Angles and Right Triangles.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. A Concise Introduction to MATLAB ® William J. Palm III.
MEGN 536 – Computational Biomechanics MATLAB: Getting Started Prof. Anthony J. Petrella Computational Biomechanics Group.
An Introduction to Programming and Algorithms. Course Objectives A basic understanding of engineering problem solving process. A basic understanding of.
ECE 1304 Introduction to Electrical and Computer Engineering Section 1.1 Introduction to MATLAB.
ENG 1181 College of Engineering Engineering Education Innovation Center MATLAB is a powerful program for numerical computations, plotting and programming.
Introduction to MATLAB ENGR 1181 MATLAB 1. Programming In The Real World Programming is a powerful tool for solving problems in every day industry settings.
Introduction to Engineering MATLAB – 1 Introduction to MATLAB Agenda Introduction Arithmetic Operations MATLAB Windows Command Window Defining Variables.
Chapter 1 An Overview Of MATLAB. The default MATLAB Desktop. Figure 1.1–1 1-2 More? See pages 6-7.
Copyright © The McGraw-Hill Companies, Inc. Introduction to MATLAB for Engineers, Third Edition William J. Palm III Chapter 1 An Overview of MATLAB.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. A Concise Introduction to MATLAB ® William J. Palm III.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Introduction to MATLAB 7 for Engineers William J. Palm.
A Brief introduction to MatLAB ($50 - $99 for students)
Chapter 1 An Overview Of MATLAB. The default MATLAB Desktop. Figure 1.1–1 1-2 More? See pages 6-7.
Introduction to Engineering MATLAB – 2 Introduction to MATLAB - 2 Agenda Defining Variables MATLAB Windows.
Introduction to Programming with RAPTOR
By Mr.Bullie. Trigonometry Trigonometry describes the relationship between the side lengths and the angle measures of a right triangle. Right triangles.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Introduction to MATLAB 7 for Engineers William J. Palm.
Chapter 3 MATLAB Fundamentals Introduction to MATLAB Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Chapter 1 – Matlab Overview EGR1302. Desktop Command window Current Directory window Command History window Tabs to toggle between Current Directory &
Getting Started with MATLAB (part 3) 1. Algebra, 2. Trig 3. The keyword ans 4. Clean up and suppress output: finalizing the software’s presentation 1.
Lecture 5 1.What is a variable 2.What types of information are stored in a variable 3.Getting user input from the keyboard 1.
Interduction to MATLAB Manal Alotaibi Mathematics department College of science King saud university.
ENG 1181 First-Year Engineering Program College of Engineering Engineering Education Innovation Center First-Year Engineering Program MAT - Introduction.
Fundamentals of Programming 20-ENFD-112 Sections 001 to 007 Instructor: Prof. Dieter Schmidt Lecture: Monday, Wednesday 3:00-3:50 Web page
The Right Triangle Right Triangle Pythagorean Theorem
1 Trigonometry Basic Calculations of Angles and Sides of Right Triangles.
EET 109 Math January 12, 2016 Week 2 Day 1. Home work format: Section number2.4 Problem number 14 Answer18.2 Show all your work.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. A Concise Introduction to MATLAB ® William J. Palm III.
Introduction to Trigonometry Right Triangle Trigonometry.
BASICS OF MATLAB Engr.Mian Shahzad Iqbal Lecturer,Telecom Department University of Engineering & Technology Taxila.
Welcome to ENGR 8 Instructor: Tom Rebold. This Week's Agenda Syllabus Introduction Math Review Force Vectors.
MATLAB (Matrix Algebra laboratory), distributed by The MathWorks, is a technical computing environment for high performance numeric computation and.
Trigonometric Functions of Angles 6. Trigonometry of Right Triangles 6.2.
Copyright © The McGraw-Hill Companies, Inc. This work is only for non-profit use by instructors in courses for which this textbook has been adopted.
Copyright © 2005 Pearson Education, Inc.. Chapter 2 Acute Angles and Right Triangles.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Introduction to MATLAB 7 for Engineers William J. Palm.
Basic operations in Matlab EE 201.  Achieve Comprehension LOL of Matlab basic operations. Class Learning Objectives 2.
Trigonometric Identities
ECE 1304 Introduction to Electrical and Computer Engineering
ECE 1304 Introduction to Electrical and Computer Engineering
Introduction to MATLAB for Engineers, Third Edition
MAC 1114 Module 2 Acute Angles and Right Triangles Rev.S08.
INTRODUCTION TO BASIC MATLAB
MATLAB DENC 2533 ECADD LAB 9.
Introduction to MATLAB 7
Experiment No. (1) - an introduction to MATLAB
MatLab Program Used to Calculate Interactive
Electrical and Computer Engineering Department SUNY – New Paltz
Presentation transcript:

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Introduction to MATLAB 7 for Engineers William J. Palm III Chapter 1 An Overview Of MATLAB PowerPoint to accompany

Matlab's capabilities Hard to describe, best shown with user stories: ries/ Hard to describe, best shown with user stories: ries/ ries/ ries/ basically takes the tedium out of doing complex, specialized, math calculations basically takes the tedium out of doing complex, specialized, math calculations some programs like MathCad help you "do math" some programs like MathCad help you "do math" Matlab is more a "Problem solving" tool. Matlab is more a "Problem solving" tool. Simulation, Verify speculative possibilities Simulation, Verify speculative possibilities Combined with programming language for extensibility Combined with programming language for extensibility

The default MATLAB Desktop. Figure 1.1–1 1-2 More? See pages 6-7.

Entering Commands and Expressions MATLAB retains your previous keystrokes. Use the up-arrow key to scroll back back through the commands. Press the key once to see the previous entry, and so on. Use the down-arrow key to scroll forward. Edit a line using the left- and right-arrow keys the Backspace key, and the Delete key. Press the Enter key to execute the command. 1-3

An Example Session >> 8/10 ans = >> 5*ans ans = 4 >> r=8/10 r = >> r r = >> s=20*r s = More? See pages 8-9.

Scalar Arithmetic Operations Table 1.1–1 1-5 Symbol Operation MATLAB form ^ exponentiation: a b a^b * multiplication: ab a*b / right division: a/b a/b \ left division: b/a a\b + addition: a + b a + b - subtraction: a - b a - b

Order of Precedence Table 1.1–2 1-6 Precedence Operation FirstParentheses, evaluated starting with the innermost pair. SecondExponentiation, evaluated from left to right. ThirdMultiplication and division with equal precedence, evaluated from left to right. FourthAddition and subtraction with equal precedence, evaluated from left to right.

Examples of Precedence >> 8 + 3*5 ans = 23 >> 8 + (3*5) ans = 23 >>(8 + 3)*5 ans = 55 >>4^2­12­ 8/4*2 ans = 0 >>4^2­12­ 8/(4*2) ans = (continued …)

Examples of Precedence (continued) >> 3*4^2 + 5 ans = 53 >>(3*4)^2 + 5 ans = 149 >>27^(1/3) + 32^(0.2) ans = 5 >>27^(1/3) + 32^0.2 ans = 5 >>27^1/3 + 32^0.2 ans =

The Assignment Operator = Typing x = 3 assigns the value 3 to the variable x. Typing x = 3 assigns the value 3 to the variable x. We can then type x = x + 2. This assigns the value = 5 to x. But in algebra this implies that 0 = 2. We can then type x = x + 2. This assigns the value = 5 to x. But in algebra this implies that 0 = 2. In algebra we can write x + 2 = 20, but in MATLAB we cannot. In algebra we can write x + 2 = 20, but in MATLAB we cannot. In MATLAB the left side of the = operator must be a single variable. In MATLAB the left side of the = operator must be a single variable. The right side must be a computable value. The right side must be a computable value. 1-9 More? See pages

Commands for managing the work session Table 1.1– CommandDescription clc Clears the Command window. clear Removes all variables from memory. clear v1 v2 Removes the variables v1 and v2 from memory. exist(‘var’) Determines if a file or variable exists having the name ‘ var ’. quit Stops MATLAB. (continued …)

Commands for managing the work session Table 1.1–3 (continued) who Lists the variables currently in memory. whos Lists the current variables and sizes, and indicates if they have imaginary parts. ;Semicolon; suppresses screen printing; also denotes a new row in an array. 1-11More? See pages

Special Variables and Constants Table 1.1– Command Description ans Temporary variable containing the most recent answer. eps Specifies the accuracy of floating point precision. i,j The imaginary unit  1. Inf Infinity. NaN Indicates an undefined numerical result. pi The number .

Complex Number Operations The number c 1 = 1 – 2i is entered as follows: c1 = 1­2i. An asterisk is not needed between i or j and a number, although it is required with a variable, such as c2 = 5 ­ i*c1. Be careful. The expressions y = 7/2*i and x = 7/2i give two different results: y = (7/2)i = 3.5i and x = 7/(2i) = –3.5i. 1-13

Numeric Display Formats Table 1.1– Command Description and Example format short Four decimal digits (the default); format long 16 digits; format short e Five digits (four decimals) plus exponent; e+03. format long e 16 digits (15 decimals) plus exponent; e–04.

Some Commonly Used Mathematical Functions Table 1.3– Function MATLAB syntax 1 e x exp(x) √x sqrt(x) ln x log(x) log 10 x log10(x) cos x cos(x) sin x sin(x) tan x tan(x) cos  1 x acos(x) sin  1 x asin(x) tan  1 x atan(x) 1 The MATLAB trigonometric functions use radian measure.

Arrays The numbers 0, 0.1, 0.2, …, 10 can be assigned to the variable u by typing u = [0:0.1:10]. To compute w = 5 sin u for u = 0, 0.1, 0.2, …, 10, the session is; >>u = [0:0.1:10]; >>w = 5*sin(u); The single line, w = 5*sin(u), computed the formula w = 5 sin u 101 times. 1-15

Problem Solving The point of learning Matlab is to help us solve problems in Engineering,Science,Math The point of learning Matlab is to help us solve problems in Engineering,Science,Math Matlab is just a tool—it won't think for us Matlab is just a tool—it won't think for us We still need to apply the engineering problem solving method We still need to apply the engineering problem solving method Much of our thought process needs to take place "offline" i.e. using traditional sketches and paper based mathematics Much of our thought process needs to take place "offline" i.e. using traditional sketches and paper based mathematics Computer tools require special care to make sure the answers are correct Computer tools require special care to make sure the answers are correct

Steps in engineering problem solving Table 1.7– Understand the purpose of the problem Collect the known information. Realize that some of it might later be found unnecessary Determine what information you must find Simplify the problem only enough to obtain the required information. State any assumptions you make Draw a sketch and label any necessary variables Determine which fundamental principles are applicable Think generally about your proposed solution approach and consider other approaches before proceeding with the details. (continued …) 1-56

Steps in engineering problem solving Table 1.7–1 (continued) 8. Label each step in the solution process. Understand the purpose of the problem 9. If you solve the problem with a program, hand check the results using a simple version of the problem. Checking the dimensions and units and printing the results of intermediate steps in the calculation sequence can uncover mistakes. (continued …) 1-57

Steps in engineering problem solving Table 1.7–1 (continued) 10. Perform a “reality check” on your answer. Does it make sense? Estimate the range of the expected result and compare it with your answer. Do not state the answer with greater precision than is justified by any of the following: (a)The precision of the given information. (b)The simplifying assumptions. (c)The requirements of the problem. Interpret the mathematics. If the mathematics produces multiple answers, do not discard some of them without considering what they mean. The mathematics might be trying to tell you something, and you might miss an opportunity to discover more about the problem. 1-58More? See pages

Steps for developing a computer solution Table 1.7– State the problem concisely Specify the data to be used by the program. This is the “input.” Specify the information to be generated by the program. This is the “output.” Work through the solution steps by hand or with a calculator; use a simpler set of data if necessary Write and run the program Check the output of the program with your hand solution Run the program with your input data and perform a reality check on the output If you will use the program as a general tool in the future, test it by running it for a range of reasonable data values; perform a reality check on the results. 1-59More? See pages

23 Rev.S08 How to Solve an Applied Trigonometry Problem? Step 1Draw a sketch, and label it with the given information. Label the quantity to be found with a variable. Step 2Use the sketch to write an equation relating the given quantities to the variable. Step 3Solve the equation, and check that your answer makes sense.

Laws of Trig you should Master Pythagorean theorem: a 2 +b 2 =c 2 (right triangles) Sum of internal angles = 180 (all triangles) Definition of sin, cos, tan, arcsin, arccos, arctan (right triangles) Law of Cosines (all triangles) Law of Sines (all triangles)

Defining sin, cos, tan also, a = c cos(  ), b = c sin(  )  = arccos(a/ c) = arcsin(b/c) = arctan(b/a)

27 Rev.S08 Example Click link to download other modules. The length of the shadow of a tree m tall is m. Find the angle of elevation of the sun. Draw a sketch. The angle of elevation of the sun is  m m B

28 Rev.S08 Example 2 Click link to download other modules. The length of the shadow of a tree is 100 ft, and the angle of elevation of the sun is 60 degrees. Find the height of the tree: 100 = hyp*cos(60), therefore hyp = 100/cos(60) = 200 height = hyp*sin(60) = 200*.866 = 173 ft

Law of Cosines Use when you know an angle and two adacent sides to find the 3 rd side Use when you know three sides and want to find an angle

Find x Matlab: x = sqrt(14^2+10^2-2*14*10*cosd(44)) = (use cosd for degree angles)

Find x paper: 25 2 = – 2*37*32*cos(x) cos(x) = ( – 25 2 ) / (2*37*32) Matlab: x = acosd(( – 25 2 ) / (2*37*32) )

Law of Sines Use when you know an angle and the opposite side and want to find another angle or side:

Find b (paper) sin(b)/16 = sin(115)/123 (matlab) b = asind( 16*sind(115)/123) = 6.77 deg (use sind for degrees)

U Try: Find unknown side x a x (paper) (matlab)