Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 MATLAB Programming Chapter 2.

Slides:



Advertisements
Similar presentations
Chapter 12 Information Systems. 2 Managing Information Information system: Software that helps us organize and analyze data.  Flexible application software.
Advertisements

Introduction to Excel Chapter 2 Excel Fundamentals Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Flow Charts, Loop Structures
Chapter 1 Computing Tools Data Representation, Accuracy and Precision Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction.
Top-Down Design with Functions 4 What do programmer’s (not programs!) use as input to the design of a program? –Documentation Problem definition Requirements.
Chapter 4 MATLAB Programming Logical Structures Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Matlab Basics IEF 217a: Lecture 2 Fall 2002 Sigmon and Davis, chapters 1-7.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Mathematical Modeling and Engineering Problem solving.
Matrix Mathematics in MATLAB and Excel
Chapter 9 Numerical Integration Numerical Integration Application: Normal Distributions Copyright © The McGraw-Hill Companies, Inc. Permission required.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 2 Image Slides.
Non-Linear Simultaneous Equations
Chapter 7 Matrix Mathematics Matrix Operations Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Chapter 8 Traffic-Analysis Techniques. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 8-1.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 ~ Linear Algebraic Equations ~ Gauss Elimination Chapter.
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.
Builtin and user defined functions
Chapter 4 MATLAB Programming Combining Loops and Logic Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Predefined MATLAB Functions ELEC 206 Computer Applications for Electrical Engineers Dr. Ron Hayne.
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 © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Introduction to MATLAB 7 for Engineers William J. Palm.
Chapter 9 Numerical Integration Flow Charts, Loop Structures Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Chapter 6 Finding the Roots of Equations
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Introduction to MATLAB 7 for Engineers William J. Palm.
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.
EECE 360/460 Matlab Tutorial Jan Outline What is Matlab? What is Matlab? Matlab Interface Matlab Interface Basic Syntax Basic Syntax Plotting Graphs.
Release Numbers MATLAB is updated regularly The Mathworks packages their software in groups, called releases, New releases are issued twice a year in the.
Slide deck by Dr. Greg Reese Miami University MATLAB An Introduction With Applications, 5 th Edition Dr. Amos Gilat The Ohio State University Chapter 1.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. A Concise Introduction to MATLAB ® William J. Palm III.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. by Lale Yurttas, Texas A&M University 1 Chapter 1 Mathematical.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Chapter 2.
1 Functions ผศ. ดร. อนันต์ ผลเพิ่ม Anan Phonphoem
Chapter 3 MATLAB Fundamentals Introduction to MATLAB Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is protected by Copyright.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Part 6 - Chapter 24 Boundary Value Problems.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 8 Lists and Tuples.
Working with Arrays in MATLAB
Computer Programming TCP1224 Chapter 11 Arrays. Objectives Using Arrays Declare and initialize a one-dimensional array Manipulate a one-dimensional array.
MATLAB Jirawat Kanjanapitak (Tae). What is MATLAB A computer program for doing numerical computation including; Arithmetic, Polynomials, Graphics, 2-D.
Lec-10 Manipulations of Matlab Matrices. Built-in functions The chapter will be covered quickly There are quite a few built-in functions in MATLAB – If.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Introduction to MATLAB 7 for Engineers William J. Palm.
Newton’s Method, Root Finding with MATLAB and Excel
Fundamentals of Programming 20-ENFD-112 Sections 001 to 007 Instructor: Prof. Dieter Schmidt Lecture: Monday, Wednesday 3:00-3:50 Web page
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Part 4 Chapter 15 General Least Squares and Non- Linear.
Introduction to MATLAB 1.Basic functions 2.Vectors, matrices, and arithmetic 3.Flow Constructs (Loops, If, etc) 4.Create M-files 5.Plotting.
MATLAB Lecture 1 염익준. Introduction MATLAB (MATrix LABoratory) a special purpose computer program optimized to perform engineering and scientific calculations.
Using and Programming with MATLAB as an Engineering Tool [ Part III ]
Chapter 2 Excel Fundamentals Logical IF (Decision) Statements Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Chapter 4 MATLAB Programming MATLAB Troubleshooting Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Part 6 - Chapters 22 and 23.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Part 2 - Chapter 7 Optimization.
Chapter 13 Transportation Demand Analysis. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display
전자장 1 실험 - Matlab 사용법 - Photonic Systems Laboratory School of EE, Seoul National University Photonic Systems Lab School of EECS, S.N.U.
Chapter 1 Computing Tools Variables, Scalars, and Arrays Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Part(2) MATLAB.
Arithmetic Operations
Numeric, Cell and Structural Arrays One of the strenghts of MATLAB is the capabilty to handle collection of numbers called ARRAYS. MATLAB refers to scalars,
Chapter 7 Matrix Mathematics
ECE 1304 Introduction to Electrical and Computer Engineering
Built-in MATLAB Functions Chapter 3
Chapter 4 MATLAB Programming
Computer Simulation Lab
Plotting Data with MATLAB
Communication and Coding Theory Lab(CS491)
Working with Arrays in MATLAB
Computer Simulation Lab
CHAPTER 3 Built-in MATLAB Functions
Presentation transcript:

Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 MATLAB Programming Chapter 2

Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 2 MATLAB a flagship software which was originally developed as a matrix library. A variety of numerical functions, symbolic computations, and visualization tools have been added to the matrix manipulations. Demo programs: % file I/O

Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 3 Sample Program g=9.8; cd=12.5; m = 68.1; dt = input('time increment (s):'); tf = input('final time (s):'); ti=0; vi=0; while (1) dvdt = g-(cd/m)*vi; vi = vi + dvdt*dt; ti = ti + dt; if ti >= tf, break, end end disp('velocity (m/s):') disp(vi) t (sec.)V (m/s) ∞53.39 m=68.1 kg; c=12.5 kg/s; g=9.8 m/s

Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 Built-in functions sqrt(x) exp(x) abs(x) log(x) log10(x) factorial(x) TRIGONEMETRIC sin(x) sind(x) cos(x) cosd(x) tan(x) tand(x) cot(x) cotd(x) Rounding functions round(x) fix(x) - round towards zero ceil(x) floor(x) rem(x,y) – returns the remainder after x is divided by y (similar to % function in C) Display formats format short : format long: format short e: e+001 format long e: e+0001 format short g: format long g: format bank: format compact: eliminates empty lines format loose: adds empty lines

Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 5 Plot function >> x=0:1:5 x = >> y = sin(10*x) + cos(3*x) y = >> plot(x,y) >> xlabel('x in radians') >> ylabel('y = sin(10*x) + cos(3*x)') >> >> z = zeros(1,6) % alternative way z=0*x z = >> plot(x,y, x,z) >> xlabel('x in radians') >> ylabel('y = sin(10*x) + cos(3*x)')

Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 6 Roots of polynomials >> r = [1, -2, 4] r = >> poly(r) ans = >> p = poly(r) p = >> solve = roots(p) solve = System of equations >> x=[-1, 5] x = -1 5 >> A = [2, 3; -1, 4] A = >> b = A*x' b = >> solveX = inv(A)*b solveX =

Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 7 Passing a function as an argument The following program plots a function (passed as an argument) between a specified range (xa, xb): function draw = myplot(func, xa, xb, inc, LabelX, LabelY) X = xa:inc:xb Y = func(X); Z = 0*X; plot(X,Y,X,Z); xlabel(LabelX); ylabel(LabelY); function f1 = myfunc(x) % stored in another file called myfunc.m f1 = sind(x); MATLAB call: >> xmin, xmax, increment, LabelX, LabelY)

Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Fundamental control structures in MATLAB Managing Variables clear – removes all variables from memory clear x y – removes only x and y from memory who – displays a list of variables in the memory whos – displays a list of variables in the memory along with their size and class FOR-Loop sum = 0; DOFOR i = start, step, final for i = 2:1:25 (Loop Body) sum = sum + A[i]; ENDDO end

Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Spreadsheet that allows the user to enter and perform calculations on rows and columns of data. When any value on the sheet is changed, entire calculation is updated, therefore, spreadsheets are ideal for “what if?” sorts of analysis. Excel has some built in numerical capabilities including equation solving, curve fitting and optimization. It has several visualization tools, such as graphs and three dimensional plots. It also includes Visual Basic (VBA) as a macro language that can be used to implement numerical calculations. check out: EXCEL

Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.