Predefined MATLAB Functions ELEC 206 Computer Applications for Electrical Engineers Dr. Ron Hayne.

Slides:



Advertisements
Similar presentations
CMPS 1371 Introduction to Computing for Engineers FUNCTIONS.
Advertisements

Introduction to MATLAB
An Anthropologist on Matlab. Data Analysis Functions (1) corrcoef(x) cov(x) cplxpair(x) cross(x,y) cumprod(x) cumsum(x) del2(A) diff(x) dot(x,y) gradient(Z,
Lecture 6 MATLAB functions Basics of Built-in Functions, Help Feature, Elementary Functions (e.g., Polynomials, Trigonometric Functions), Data Analysis,
Matrices. Special Matrices Matrix Addition and Subtraction Example.
Introduction to MATLAB 7 for Engineers
Matlab Basics IEF 217a: Lecture 2 Fall 2002 Sigmon and Davis, chapters 1-7.
EGR 106 Intro to Engineering II Engineering problem solving using MATLAB Text: Amos Gilat, MATLAB An Introduction with Applications, Wiley 2004 ISBN
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Introduction to MATLAB 7 for Engineers William J. Palm.
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
EGR 106 Intro to Engineering II Engineering problem solving using MATLAB Text: Amos Gilat, MATLAB An Introduction with Applications, Wiley 2004 ISBN
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 © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 MATLAB Programming Chapter 2.
ME 142 Engineering Computation I Excel Functions.
ME 142 Engineering Computation I Excel Functions.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Introduction to MATLAB 7 for Engineers William J. Palm.
Arrays ELEC 206 Computer Applications for Electrical Engineers Dr. Ron Hayne.
Introduction to MATLAB Computational Probability and Statistics CIS 2033 Section 003 Djordje Gligorijevic, Temple University, Fall 2015.
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.
MATLAB An Introduction to MATLAB (Matrix Laboratory) 1.
Matlab for Engineers Built-in Matlab Functions Chapter 3.
CMPS 1371 Introduction to Computing for Engineers MATRICES.
Matrix Computations ELEC 206 Computer Applications for Electrical Engineers Dr. Ron Hayne.
1 Functions ผศ. ดร. อนันต์ ผลเพิ่ม Anan Phonphoem
STANDARD FUNCTIONS Computer Programming Asst. Prof. Dr. Choopan Rattanapoka and Asst. Prof. Dr. Suphot Chunwiphat.
Recap Script M-file Editor/Debugger Window Cell Mode Chapter 3 “Built in MATLAB Function” Using Built-in Functions Using the HELP Feature Window HELP.
MATLAB Environment ELEC 206 Computer Applications for Electrical Engineers Dr. Ron Hayne.
Recap Sum and Product Functions Matrix Size Function Variance and Standard Deviation Random Numbers Complex Numbers.
Introduction to Matlab
Introduction to MATLAB ENGR 1181 MATLAB 1. Opening MATLAB  Students, please open MATLAB now.  CLICK on the shortcut icon → Alternatively, select… start/All.
Matlab Basics FIN250f: Lecture 3 Spring 2010 Grifths Web Notes.
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is protected by Copyright.
Visual Basic I Programming
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.
C++ Programming Lecture 9 Functions – Part I By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
Two-Dimensional Arrays ELEC 206 Computer Applications for Electrical Engineers Dr. Ron Hayne.
Matrix Computations ELEC 206 Computer Applications for Electrical Engineers Dr. Ron Hayne.
(The Transpose Operator) 1 >> C=[ ; ; ] C = >> D=C' D =
ENG 1181 First-Year Engineering Program College of Engineering Engineering Education Innovation Center First-Year Engineering Program MAT - Introduction.
1 CS1371 Introduction to Computing for Engineers Control Statements 9/4/2003.
September 15, 2005 Lecture 5 - By Paul Lin 1 CPET 190 Lecture 5 Problem Solving with MATLAB
Program design and algorithm development We will consider the design of your own toolbox to be included among the toolboxes already available with your.
Lecture 24: Rough and Ready Analysis. MATLAB uses function names consistent with most major programming languages For example sqrt sin cos log.
MATLAB Lecture 1 염익준. Introduction MATLAB (MATrix LABoratory) a special purpose computer program optimized to perform engineering and scientific calculations.
Some “What’s the output” questions to get the day started… >>A = [1 2 3; 3 5 6] This statement stores the matrix: 1. A= 2. A= 3. A= 4. A= Ask Garvin’s.
Part(2) MATLAB.
Introduction To MATLAB
Arithmetic Operations
Introduction to Matlab
ECE 1304 Introduction to Electrical and Computer Engineering
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,
ECE 1304 Introduction to Electrical and Computer Engineering
Built-in MATLAB Functions Chapter 3
EGR 115 Introduction to Computing for Engineers
BIL 104E Introduction to Scientific and Engineering Computing
Computer programming Dr. Ivan A. Hashim.
Computer Simulation Lab
INTRODUCTION TO MATLAB AM2032 JAYANTA MUKHERJEE.
18. More Solving Equations
Fourth Year – Software Engineering
Vectors, matrices, and arithmetic
Announcements P3 due today
Computer Simulation Lab
MatLab Program Used to Calculate Interactive
Introduction to Matlab
CHAPTER 3 Built-in MATLAB Functions
Presentation transcript:

Predefined MATLAB Functions ELEC 206 Computer Applications for Electrical Engineers Dr. Ron Hayne

206_M32 Elementary Math Functions abs(x) sqrt(x) sign(x) round(x), fix(x) ceil(x), floor(x) rem(x,y) exp(x) log(x), log2(x), log10(x)

206_M33 Trigonometric Functions  Angle in radians(180 degrees = pi radians) sin(x), cos(x), tan(x) asin(x), acos(x), atan(x)  Angle in degrees sind(x), cosd(x), tand(x) asind(x), acosd(x), atand(x) angle_deg = angle_rad*(180/pi); angle_rad = angle_deg*(pi/180);

206_M34 Data Analysis Functions  Minimum and Maximum max(x), [a,b]=max(x), max(x,y) min(x), [a,b]=min(x), min(x,y)  Averages median(x), mean(x), std(x)  Sums and Products sum(x), prod(x) cumsum(x), cumprod(x)

206_M35 Data Analysis Functions  Sorting sort(x)  Size size(x), [a,b]=size(x) length(x)

206_M36 Random Numbers  Uniform Random Numbers rand('seed',n), rand(n), rand(m,n) Interval 0 to 1 Interval a to b x = (b - a)*r + a;  Gaussian Random numbers randn('seed',n), randn(n), randn(m,n) Normal Distribution Mean = 0, Standard Deviation = 1.0 Modified Distribution Mean = b, Standard Deviation = a x = a*r + b;

206_M37 Problem Solving Applied  Weather Data Problem Statement Using the data in the file Weather_Data.xls, find the total monthly precipitation, the total precipitation for the year, and the day on which it rained the most. Input/Output Description Total Monthly Precipitation Total Precipitation Weather_Data.xls Day of Most Rain

206_M38 Problem Solving Applied Hand Example 12x31 Matrix  Rows = Months  Columns = Days  Hundreths of inches  Invalid = tot_jan = 2.72 in tot_feb = 1.66 in tot_jan+feb = 4.38 in max = Jan

206_M39 Problem Solving Applied Algorithm Development Import spreadsheet into matrix Change values to 0 Interchange rows and columns Monthly Totals (inches) = sum columns/100 Yearly Total = sum Monthly Totals Find max and location

206_M310 MATLAB Solution

206_M311 MATLAB Solution clc % Example Weather Data % Find the total precipitation for each month, and % for the entire year, using a data file % wd=Weather_Data; wd(2,29)=0; % Change values to 0 wd(2,30)=0; wd(2,31)=0; wd(4,31)=0; wd(6,31)=0; wd(9,31)=0; wd(11,31)=0;

206_M312 MATLAB Solution % Use transpose operator to change rows to columns wd = wd'; % Sum of each column is sum for each month monthly_total = sum(wd)/100 % Find the annual total yearly_total = sum(monthly_total) % Find the annual maximum, and month [maximum_precip,month] = max(max(wd)); % Find the annual maximum, and day [maximum_precip,day] = max(max(wd')); % Print max data maximum_precip = maximim_precip/100 month day

206_M314 Manipulating Matrices  Defining Matrices A = [1 2 3; 4 5 6]; (2x3) A = [1 2 3; 4 5 6]; B = [1 2 3] (1x3) B = [ ]; C = [A; B] = [1 2 3; 4 5 6; 1 2 3]; (3x3)

206_M315 Manipulating Matrices  Changing Matrices D = [3 4 5]; D(2) = 8; D = D(5) = 7; D =

206_M316 Manipulating Matrices  Defining Matrices with the Colon Operator E = 1:4 E = F = 0.0:0.5:2.0 F =

206_M317 Manipulating Matrices  Extracting Data with the Colon Operator G = [1 2 3; 2 3 4; 3 4 5; 4 5 6]; x = G(3, :) x = y = G(:, 2:3) y =

206_M318 Manipulating Matrices  Extracting Data with the Colon Operator G = [1 2 3; 2 3 4; 3 4 5; 4 5 6]; G(3,2) ans = 4 G(7) ans = 4 G(:) ans =

206_M319 Computational Limitations  Double Range to  Exponent Overflow y = 2e200; y^2 ans = Inf  Exponent Underflow x = 2e-200 x/y ans = 0  Double Precision eps ans = e-016  Divide by Zero y/0 ans = Inf 0/0 ans = NaN

206_M320 Special Values and Functions  Special Values pi i j Inf NaN  Special Functions clock Year Month Day Hour Minute Seconds date dd-Mth-yyyy

206_M321 Summary  MATLAB Functions Math, Trig, Data Analysis, Random Numbers  Problem Solving Applied  Manipulating Matrices  Special Values and Functions  End of Chapter Summary MATLAB Summary Characters, Commands and Functions Key Terms