MATLAB ME1107 Y Yan Reference: MATLAB for Engineers by Holly Moore (Pearson Prentice Hall)

Slides:



Advertisements
Similar presentations
Introduction to Matlab
Advertisements

Introduction to MATLAB for Biomedical Engineering BME 1008 Introduction to Biomedical Engineering FIU, Spring 2015 Lesson 2: Element-wise vs. matrix operations.
Introduction to Matlab EE 2303 Lab. MATLAB stands for “Matrix Laboratory” APPLICATIONS OF MATLAB:  Mathematical Calculations  Data Analysis & Visualization.
Maths for Computer Graphics
Introduction to Matlab By: Dr. Maher O. EL-Ghossain.
Arrays A variable: a named position of memory For example: x1, x2, x3……..x10 An array: a collection of variables of the same type that are referenced by.
Introduction to MATLAB
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.
Mathcad Variable Names A string of characters (including numbers and some “special” characters (e.g. #, %, _, and a few more) Cannot start with a number.
MATLAB Basics With a brief review of linear algebra by Lanyi Xu modified by D.G.E. Robertson.
MATLAB INTRO CONTROL LAB1  The Environment  The command prompt Getting Help : e.g help sin, lookfor cos Variables Vectors, Matrices, and Linear Algebra.
Nonparametric Econometrics1 Intro to Matlab for Data Analysis and Statistical Modeling.
Introduction to MATLAB Zongqiang Liao Research Computing Group UNC-Chapel Hill.
Introduction to Matlab 1. Outline: What is Matlab? Matlab Screen Variables, array, matrix, indexing Operators Plotting Flow Control Using of M-File Writing.
1 Computer Programming (ECGD2102 ) Using MATLAB Instructor: Eng. Eman Al.Swaity Lecture (2): MATLAB Environment (Chapter 1)
IC3003 B ASIC S CIENTIFIC C OMPUTING Lecture 1 Monday 08:30-11:30 U204a.
1 Lab of COMP 406 Teaching Assistant: Pei-Yuan Zhou Contact: Lab 1: 12 Sep., 2014 Introduction of Matlab (I)
MEGN 536 – Computational Biomechanics MATLAB: Getting Started Prof. Anthony J. Petrella Computational Biomechanics Group.
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.
Computational Methods of Scientific Programming Lecturers Thomas A Herring, Room A, Chris Hill, Room ,
Introduction to Engineering MATLAB – 6 Script Files - 1 Agenda Script files.
INTRODUCTION TO MATLAB LAB# 01
Matlab Basics Tutorial. Vectors Let's start off by creating something simple, like a vector. Enter each element of the vector (separated by a space) between.
What is MATLAB? MATLAB is one of a number of commercially available, sophisticated mathematical computation tools. Others include Maple Mathematica MathCad.
Introduction to Engineering MATLAB – 2 Introduction to MATLAB - 2 Agenda Defining Variables MATLAB Windows.
10/24/20151 Chapter 2 Review: MATLAB Environment Introduction to MATLAB 7 Engineering 161.
MATLAB Harri Saarnisaari, Part of Simulations and Tools for Telecommunication Course.
Advanced Topics- Functions Introduction to MATLAB 7 Engineering 161.
MATLAB Environment ELEC 206 Computer Applications for Electrical Engineers Dr. Ron Hayne.
Lecture 2 - Matlab Introduction CVEN 302 June 5, 2002.
Introduction to MATLAB ENGR 1181 MATLAB 1. Opening MATLAB  Students, please open MATLAB now.  CLICK on the shortcut icon → Alternatively, select… start/All.
Chapter 3 MATLAB Fundamentals Introduction to MATLAB Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
ME6104: CAD. Module 4. ME6104: CAD. Module 4. Systems Realization Laboratory Module 4 Matlab ME 6104 – Fundamentals of Computer-Aided Design.
1 Week 1: Variables, assignment, expressions READING: 1.2 – 1.4.
1 DKT 211 Basic Communication Engineering LAB # 1A : (Lecture 1) Introduction to Matlab  Basic Features  Scientific features  Array Operations  Script.
Chapter 6 Review: User Defined Functions Introduction to MATLAB 7 Engineering 161.
MA/CS 375 Fall 2002 Lecture 3. Example 2 A is a matrix with 3 rows and 2 columns.
Introduction to Matlab. What is Matlab? A software environment for interactive numerical computations Examples:  Matrix computations and linear algebra.
CS 170 – INTRO TO SCIENTIFIC AND ENGINEERING PROGRAMMING.
Recap Saving Plots Summary of Chapter 5 Introduction of Chapter 6.
MATLAB Lecture Two Tuesday 5 July Chapter 3.
Computer Simulation Lab Electrical and Computer Engineering Department SUNY – New Paltz SUNY-New Paltz “Lecture 2”
1 Lecture 1 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept.
EGR 115 Introduction to Computing for Engineers Introduction to MATLAB Friday 29 August 2014 EGR 115 Introduction to Computing for Engineers.
Lecture 20: Choosing the Right Tool for the Job. What is MATLAB? MATLAB is one of a number of commercially available, sophisticated mathematical computation.
Lecture 26: Reusable Methods: Enviable Sloth. Creating Function M-files User defined functions are stored as M- files To use them, they must be in the.
Interduction to MATLAB Manal Alotaibi Mathematics department College of science King saud university.
Introduction to Matlab  Matlab is a software package for technical computation.  Matlab allows you to solve many numerical problems including - arrays.
ENG 1181 First-Year Engineering Program College of Engineering Engineering Education Innovation Center First-Year Engineering Program MAT - Introduction.
Introduction to Matlab
MATLAB for Engineers, by Holly Moore. ISBN © 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is.
Introduction to MATLAB Zongqiang Liao Research Computing Group UNC-Chapel Hill.
Introduction to Matlab Electromagnetic Theory LAB by Engr. Mian Shahzad Iqbal.
The Hong Kong Polytechnic University Industrial Centre MatLAB Lesson 1 : Overview & Environment Edward Cheung Room W311g.
Introduction to MATLAB 1.Basic functions 2.Vectors, matrices, and arithmetic 3.Flow Constructs (Loops, If, etc) 4.Create M-files 5.Plotting.
MA/CS 375 Fall 2002 Lecture 2. Motivation for Suffering All This Math and Stuff Try the Actor demo from
Introduction to Matlab Patrice Koehl Department of Biological Sciences National University of Singapore
Math 252: Math Modeling Eli Goldwyn Introduction to MATLAB.
Matlab Tutorial Iman Moazzen First Session – September 11, 2013.
Matrix Algebra Definitions Operations Matrix algebra is a means of making calculations upon arrays of numbers (or data). Most data sets are matrix-type.
전자장 1 실험 - Matlab 사용법 - Photonic Systems Laboratory School of EE, Seoul National University Photonic Systems Lab School of EECS, S.N.U.
Introduction to MATLAB Mark Reed Zongqiang Liao Research Computing Group UNC-Chapel Hill.
Jake Blanchard University of Wisconsin Spring 2006.
Introduction to Matlab
Lecture: MATLAB Chapter 1 Introduction
MATLAB DENC 2533 ECADD LAB 9.
Introduction To MATLAB
MATH 493 Introduction to MATLAB
Presentation transcript:

MATLAB ME1107 Y Yan Reference: MATLAB for Engineers by Holly Moore (Pearson Prentice Hall)

Introduction Matlab: Matrix Laboratory MATLAB is a large application program. It was originally written in FORTRAN and later rewritten in C. System software runs the computer hardware, e.g. operating systems, device drivers…. Programming software helps to write computer programs, e.g. Salford Plato IDE. Application software helps users to do specific tasks, e.g. Word, Excel… Functions: scientific calculator computer programming Strengths: matrix calculations and graphics

Use MATLAB as a calculator Basic mathematical operators: +, -, *, /, ^ Build-in functions: pi, sqrt, sin, cos, log, tan, asin, acos, atan……. Use Matlab to evaluate:

Variables and keywords Matlab is case sensitive Always use lowercase to avoid mistakes Variables 1. All name must start with a letter 2. The allowable characters are letters, numbers and the underscore >> isvarname time >> isvarname cool-beans 3. Not in the reserved keyword list >> iskeyword 4. Variables could reassign built-in or user-defined function names >> sin(pi/2) >> sin = 1 >> sin >> sin(pi/2) >> which sin Clear 1. Workspace Window keeps track of the variables 2. Clear one variable >> clear sin 3. Clear all variables >> clear all

Use MATLAB help Format >>format short >>area = pi*3.7^2 >>format long >>area = pi*3.7^2 Find out the difference between format long / format short. 1)Search for FORMAT in the help window 2)>>help format Magic Squares - coursework How to create a magic square? How to prove the matrix is a magic square?

Matrix and matrix operations - 1 Create a 1-D matrix ( 1 row) t=linspace(t1,t2,N) x=linspace(0,20,100) x=linspace(0,2*pi,100) t = t1 : dt : t2 x = 0 : 0.2 : 20 x = 0 : pi/50 : 2*pi x = [ ] x = [1, 5, 6, 9, 7, 1] Transpose 1 row to 1 column x = x’ Create a 3x3 matrix x = [ 1 1 1; 1 2 3; 1 3 6]

Matrix and matrix operations - 2 Matrix multiplication Given two matrices A = (a ij ) and B = (b ij ) we can only find AB if the number of columns of A is the same as the number of rows of B. Suppose that A is m-by-n and B is n-by-p, then C = A*B is an m-by-p matrix where the elements of C, c ij, are given by c ij = a i1 b 1j + a i2 b 2j a in b nj = i.e. To get the ij element of C, multiply the elements of row i from A with the corresponding elements of column j from B and add. Array multiplication A.*B denotes element-by-element multiplication. A and B must have the same dimensions unless one is a scalar. Suppose that A and B are two m-by-n matices, then C = A.*B is an m-by-n matrix where the elements of C, cij, are given by c ij = a ij b jj

Matrix and matrix operations - 3 times and mtimes array multiply: element-by-element multiplication, e.g. times(x, y) or x.*y matrix multipy: matrix product, e.g. mtimes(x, y) or x*y >> x= [ ] >> x=x*pi/180 >> y=sin (x) >> z=sqrt(x).*y Operator list >> help * Combine 2 1-D matrices into 1 2-D matrix Temperature conversion: C2F >> c=[-100:20:100] >> f=(9/5)*c +32 >> temperature= [c’, f’]

Plotting Graphs Plot y = sin(x) and z = cos(x) x= 0:pi/20:pi/2; y= sin(x); z= cos(x); plot (x, y, 'r-*', x, z,'g--o') legend ( ‘sin(x)',‘cos(x)') xlabel ('x'), ylabel('functions') title ('plot created by Y Yan')

Script M-files A Script M-file is a list of MATLAB statements that are saved in a file Comment operator: % (percentage sign) Display the comment lines at the beginning >> help lecture1 To list all M-files in the current folder: >> what To execute, typing the name in the command window or use the ‘save&run’ button or used in another M-file When used in another M-file, uses the same workspace >> test_lecture1 Coursework Q1: circle.m

Function M-files Function M-files: user-defined functions Function defination line function [x, y, z] = lecture1fn(xmin, xmax, N) M-file name: lecture1fn.m Input argument: xmin, xmax, N Output: three arrays - x, y, z How to use the function: in the command window or used in another M-file >> lecture1fn(0, 0.5, 20); >> [u, v, w] = lecture1fn(0, 0.5, 20) Variables in a function DO NOT share the same workspace Coursework Q2: circlefn.m