ECEN/MAE 3723 – Systems I MATLAB Lecture 1. Lecture Overview  Introduction and History  Matlab architecture  Operation basics  Visualization  Programming.

Slides:



Advertisements
Similar presentations
Introduction to Matlab
Advertisements

Introduction to MATLAB The language of Technical Computing.
Introduction to Matlab
Introduction to Matlab Workshop Matthew Johnson, Economics October 17, /13/20151.
Lecture 5 Review Programming Program Structures Comparison Repetition: looping or iteration Conditional execution: branching Bubble Sort.
CSci 2031: Matlab Tutorial Guoquan (Paul) Huang Jan 24, 2008.
Introduction to Matlab By: Dr. Maher O. EL-Ghossain.
Introduction to MATLAB Northeastern University: College of Computer and Information Science Co-op Preparation University (CPU) 10/22/2003.
Programming in MATLAB Week 14 – 4/28/09 Kate Musgrave
1 ECEN Automatic Control Systems Matlab Lecture 1 Introduction and Control Basics Presented by Moayed Daneshyari OKLAHOMA STATE UNIVERSITY.
Matlab Basics IEF 217a: Lecture 2 Fall 2002 Sigmon and Davis, chapters 1-7.
Introduction to MATLAB MECH 300H Spring Starting of MATLAB.
Introduction to programming in MATLAB MATLAB can be thought of as an super-powerful graphing calculator Remember the TI-83 from calculus? With many more.
Digital Image Processing Lecture3: Introduction to MATLAB.
EPSII 59:006 Spring Topics Using TextPad If Statements Relational Operators Nested If Statements Else and Elseif Clauses Logical Functions For Loops.
MATLAB and SimulinkLecture 11 To days Outline  Introduction  MATLAB Desktop  Basic Features  Branching Statements  Loops  Script file / Commando.
Nonparametric Econometrics1 Intro to Matlab for Data Analysis and Statistical Modeling.
Introduction to MATLAB January 18, 2008 Steve Gu Reference: Eta Kappa Nu, UCLA Iota Gamma Chapter, Introduction to MATLAB,
Objectives Understand what MATLAB is and why it is widely used in engineering and science Start the MATLAB program and solve simple problems in the command.
A L I MAM M OHAMMAD B IN S AUD I SLAMIC U NIVERSITY C OLLEGE OF S CIENCES D EPARTMENT OF M ATHEMATICS MATLAB 251 : MATH SOFTWARE Introduction to MATLAB.
ELG 3120 Signal and System Analysis 1 Introduction to MATLAB TAs Wei Zhang Ozgur Ekici (Section A)(Section B) ELG 3120 Lab Tutorial 1.
MEGN 536 – Computational Biomechanics MATLAB: Getting Started Prof. Anthony J. Petrella Computational Biomechanics Group.
A Brief Introduction to Matlab Laila Guessous Dept. of Mechanical Engineering Oakland University.
Computational Methods of Scientific Programming Lecturers Thomas A Herring, Room A, Chris Hill, Room ,
MATLAB Tutorial EE 327 Signals and Systems 1. What is MATLAB? MATLAB – Matrix Laboratory The premier number-crunching software Extremely useful for signal.
Eng Ship Structures 1 Introduction to Matlab.
INTRODUCTION TO MATLAB LAB# 01
1 Computer Programming (ECGD2102 ) Using MATLAB Instructor: Eng. Eman Al.Swaity Lecture (1): Introduction.
CMPS 1371 Introduction to Computing for Engineers MatLab.
10/24/20151 Chapter 2 Review: MATLAB Environment Introduction to MATLAB 7 Engineering 161.
MAE 1202: AEROSPACE PRACTICUM An Introduction to MATLAB: Part 2 Mechanical and Aerospace Engineering Department Florida Institute of Technology Developed.
Introduction to MATLAB
Matlab The language of Technical computing Mr. D. Suresh Assistant Professor, Dept. of CSE, PSNA CET, Dindigul.
What does C store? >>A = [1 2 3] >>B = [1 1] >>[C,D]=meshgrid(A,B) c) a) d) b)
Computational Methods of Scientific Programming Lecturers Thomas A Herring, Room , Chris Hill, Room ,
Lecture 2 - Matlab Introduction CVEN 302 June 5, 2002.
Matlab Basics FIN250f: Lecture 3 Spring 2010 Grifths Web Notes.
Matlab Screen  Command Window  type commands  Current Directory  View folders and m-files  Workspace  View program variables  Double click on a.
Introduction to Matlab By E. Noura Semary. Contents MATLAB Environment  Command window, Workspace, Path window, Editor window,and Figure window) Basic.
Computer Simulation Lab Electrical and Computer Engineering Department SUNY – New Paltz SUNY-New Paltz “Lecture 2”
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.
A simple classification problem Extract attributes Pattern Pattern recognition decision x C1 C2.
Introduction to Matlab  Matlab is a software package for technical computation.  Matlab allows you to solve many numerical problems including - arrays.
Introduction to Matlab
INTRODUCTION TO MATLAB Dr. Hugh Blanton ENTC 4347.
Introduction to MATLAB 1.Basic functions 2.Vectors, matrices, and arithmetic 3.Flow Constructs (Loops, If, etc) 4.Create M-files 5.Plotting.
Introduction to Matlab Patrice Koehl Department of Biological Sciences National University of Singapore
Matlab Tutorial 1 David Goldstein University of Colorado Dept of Aerospace Engineering Sciences.
NET 222: COMMUNICATIONS AND NETWORKS FUNDAMENTALS ( NET 222: COMMUNICATIONS AND NETWORKS FUNDAMENTALS (PRACTICAL PART) Tutorial 2 : Matlab - Getting Started.
SCRIPTS AND FUNCTIONS DAVID COOPER SUMMER Extensions MATLAB has two main extension types.m for functions and scripts and.mat for variable save files.
Introduction to Programming on MATLAB Ecological Modeling Course Sep 11th, 2006.
Introduction to Matlab Engr. Mian Shahzad Iqbal LAB NO.2
An Introduction to Programming in Matlab Emily Blumenthal
Introduction to Matlab. Outline:  What is Matlab? Matlab Screen Variables, array, matrix, indexing Operators.
Matlab Programming for Engineers
Introduction to MATLAB
Computer Application in Engineering Design
Matlab Training Session 4: Control, Flow and Functions
Lecture: MATLAB Chapter 1 Introduction
MatLab Programming By Kishan Kathiriya.
Outline Matlab tutorial How to start and exit Matlab Matlab basics.
MATLAB DENC 2533 ECADD LAB 9.
Introduction to Matlab
Matlab Workshop 9/22/2018.
StatLab Matlab Workshop
ECEN Automatic Control Systems Introduction and Control Basics
Use of Mathematics using Technology (Maltlab)
StatLab Workshop: Intro to Matlab for Data Analysis and Statistical Modeling 11/29/2018.
Digital Image Processing
1 ECEN Automatic Control Systems Matlab Lecture 1 Introduction and Control Basics Presented by Moayed Daneshyari OKLAHOMA STATE UNIVERSITY.
Presentation transcript:

ECEN/MAE 3723 – Systems I MATLAB Lecture 1

Lecture Overview  Introduction and History  Matlab architecture  Operation basics  Visualization  Programming  Other useful information

Introduction and History  Invented by Cleve Moler in late 1970s to give students access to LINPACK and EISPACK without having to learn Fortran.  Together with Jack Little and Steve Bangert they founded Mathworks in 1984 and created Matlab.  The current version is 7.  Interpreted-code based system in which the fundamental element is a matrix.  Available for a large number of platforms: Windows, Linux, HP-UX, Mac OS X and Solaris

Architecture  Currently, the Matlab core contains a mixture of routines in C and Java  New routines can be obtained by acquiring toolboxes Control systems, signal processing, image processing, neural networks, fuzzy logics, among many others.  Simulink is one of their major toolboxes

Architecture (2)  Simulink is a software package for making modeling and simulation easy and fun. It is all based on block diagrams.

Architecture (3) MATLAB (Code in C & Java) Toolbox Signal Processing Toolbox Control Systems SIMULINK …

Operation Basic  Interface: Workspace Or Launch Pad Command History or Current Directory Command Window

Operations Basics (2)  4 basic variable types: Double precision matrices Strings Cell arrays Structures  Variable assignment Single value: a = Matrix: m = [1 2; 4 3] m = a = 8

Operations Basics (3)  Using variables in expressions b = sqrt(a*10 + 1)/10  Using functions Single outputs  y = sqrt(x) Multiple outputs:  [r,p,k] = residue(num,den)  Partial-fraction expansion b = 0.9

Operations Basics (4)  Example function: Partial-fraction expansion num = [ ] den = [ ] [r,p,k] = residue(num,den) r = p = k = 1 2

Operations Basics – Matrices >> v = [1 2,3,4,5] >> v' ans = >> v(4) ans = 4 1x5 matrix transpose(v) gives 5x1 matrix 4 th element

Operations Basics – Matrices (2)  Matrix multiplication [1 2; 3 4]*[1 0; 0 1] ans =  Dot multiplication [1 2; 3 4].*[1 0; 0 1] ans =  Dot division (./), Kronecker tensor product (kron(M,N))

Operations Basics – Matrices (3)  Other important matrix functions: Inverse: inv(M) Rank: rank(M) Determinant: det(M) null matrix: M = [] n by m matrix of zeros: M = zeros(n,m) n by m matrix of ones: M = ones(n,m) Identity matrix n by n: M = eye(n)

Visualization  Matlab is great for plotting functions  x = [0:0.01:2*pi];  y = cos(x);  plot(x,y) X is in the range from 0 to 2π varying by 0.01 Do not show me the result on screen The cosine of a matrix is a matrix of the cos of each x-value

Visualization (2)  Add titles to graphs and axis title(‘this is the title’) ylabel(‘y’) xlabel(‘x’)

Visualization (3)  Multiple plots plot(x,y1,’b-’,x,y2,’r:’) legend(‘y1’,’y2’)

Visualization (4)  Matlab can also do 3D plots, such as mesh surfaces: [X,Y] = meshgrid(-2:.2:2, -2:.2:2); Z = X.* exp(-X.^2 - Y.^2); mesh(X,Y,Z)

Visualization (5)  Or simple 3D plots: x = -2:.02:2; y = x; z = x.* exp(-x.^2 - y.^2); Plot3(x,y,z,’.’)

Visualization (6)  All calls to plot, plot3, mesh, etc. will overwrite on the “current figure”. Make sure that you want to erase the “current figure”.  To create a new empty figure, use the command figure

Visualization (6)  Adding figures to reports: Print the figure directly Save it to a TIFF file and add to the report (File  Export…) Copy to clipboard and paste to the report (Edit  Copy Figure)  The background is copied too! By default it is gray. To change the background color use:  set(gcf,’color’,’white’)

Programming  Programming in Matlab is done by creating “.m” files. File  New  M-File edit  Programs can be divided into two categories: Script programs Functions

Programming (2)  Script M-files Storing a sequence of functions All variables are global Call the program by writing the name of the file where it is saved “%” can be used for commenting

Programming (3)  Functions M-files It has to start declaring the name of the function, its inputs and outputs  E.g. function [a, b, c] = foo(in1, in2) The file name has to be the same name of the function (foo.m) The variables are local Call it by calling the function name with inputs and outputs

Programming (4)  To create a new script M-file: Go to FILE -> NEW -> M-file Save file as filename.m To run the file - In the Command Window, type filename t=0:0.1:30; x=exp(-.1*t).*sin(2/3*t); axis([ ]); plot(t,x); grid ylabel('x(t)') xlabel('Time (sec)') M-file Editor

Programming (5)  Matlab accepts if-then-else constructs if elseif else end

Programming (6)  For loops for k= end The commands are executed repeatedly and the variable k is given each value in the loop-vector

Programming (7)  Example of using “if-elseif-then” and “for” command a=randn(1,5); for i=1:length(a) if a(i)>0, s(i)=1; elseif a(i)==0, s(i)=0; else s(i)=-1; end >>a = >>s = randn : scalar value drawn from a normal distribution with mean 0 and standard deviation 1

Programming (8)  Other important Control Flow functions: if statement for statement while statement No goto statement! break exists from for and while loops switch case otherwise end combination try catch end combination end is to end control statements above return is used in functions in the same way as Fortran

Other useful information  To run programs, they have to be in the current active directory or in a directory in the path (File  Set path...)  help displays the help for the function If you create function, the first things commented (%) after the function declaration are considered the help information  Helpdesk brings up a GUI for browsing very comprehensive help documents

Other useful information (2)  save saves everything in the workspace (or the function variable space) to.mat. If no is given, saves to matlab.mat.  load loads the file.  More information on Matlab software visit