Introduction to MATLAB

Slides:



Advertisements
Similar presentations
259 Lecture 17 Working with Data in MATLAB. Overview  In this lecture, we’ll look at some commands that are useful for working with data!  fzero  sum,
Advertisements

Plotting Selim Aksoy Bilkent University Department of Computer Engineering
Lecture (4) Plotting & Programming (1) Eng. Osama Talaat 1.
2D Plots 1 ENGR 1181 MATLAB 12.
Introduction to Graphing Using MATLAB. Line Graphs  Useful for graphing functions  Useful for displaying data trends over time  Useful for showing.
Slide deck by Dr. Greg Reese Miami University MATLAB An Introduction With Applications, 5 th Edition Dr. Amos Gilat The Ohio State University Chapter 3.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Introduction to MATLAB 7 for Engineers William J. Palm.
MA/CS375 Fall MA/CS 375 Fall 2002 Lecture 4.
Introduction to MATLAB Northeastern University: College of Computer and Information Science Co-op Preparation University (CPU) 10/27/2003.
Introduction to MATLAB Northeastern University: College of Computer and Information Science Co-op Preparation University (CPU) 10/22/2003.
Introduction to MATLAB Northeastern University: College of Computer and Information Science Co-op Preparation University (CPU) 10/27/2003.
MATLAB - Lecture 22A Two Dimensional Plots / Chapter 5 Topics Covered:
Vectors and Plotting Selim Aksoy Bilkent University Department of Computer Engineering
Introduction to MATLAB Northeastern University: College of Computer and Information Science Co-op Preparation University (CPU) 10/29/2003.
Introduction to MATLAB for Engineers, Third Edition William J. Palm III Chapter 7 Statistics, Probability, and Interpolation PowerPoint to accompany Copyright.
Introduction to Matlab 332:202 Discrete Mathematics Spring 2007.
EPSII 59:006 Spring Outline Managing Your Session File Usage  Saving Workspace  Loading Data Files  Creating M-files More on Matrices Review.
PLOTS AND FIGURES DAVID COOPER SUMMER Plots One of the primary uses for MATLAB is to be able to create publication quality figures from you data.
ENG College of Engineering Engineering Education Innovation Center 1 2D Plots 1 in MATLAB Topics Covered: 1.Plotting basic 2-D plots The plot()
„  1999 BG Mobasseri1 9/18/2015 June 2 GRAPHICS IN MATLAB- PART I BASIC PLOTTING.
ELG 3120 Signal and System Analysis 1 Introduction to MATLAB TAs Wei Zhang Ozgur Ekici (Section A)(Section B) ELG 3120 Lab Tutorial 1.
Lecture 2 - Matlab Introduction CVEN 302 June 5, 2002.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. A Concise Introduction to MATLAB ® William J. Palm III.
Barbara/Pratik/Yu. Outline Matlab desktop M-files Variables Arrays Plots.
ENG 1181 College of Engineering Engineering Education Innovation Center MATLAB – 2D Plots 1 Go to the class drive: ---> MatLab - Graphing ---> Seed Files.
Matlab Screen  Command Window  type commands  Current Directory  View folders and m-files  Workspace  View program variables  Double click on a.
Plot (x-values, y-values) >> x = linspace (-3, 3, 20); >> x = linspace (-3, 3, 20); >> y = 2*x – 1; >> y = 2*x – 1; >> plot (x, y) >> plot (x, y)
Introduction to Scientific Programming in MATLAB Michael McLennan Software Architect HUBzero™ Platform for Scientific Collaboration.
EGR 106 Lecture 6 2-D Plotting Graphical presentation has become the standard method to show technical information. Engineers use plots to analyze, visualize,
EGR 115 Introduction to Computing for Engineers 2D Plotting – Part I Wednesday 17 Sept 2014 EGR 115 Introduction to Computing for Engineers.
Introduction To Matlab Class 4 Instructors: Hristiyan (Chris) Kourtev and Xiaotao Su, PhD Double click the matlab icon When prompted click “Skip”
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Introduction to MATLAB 7 for Engineers William J. Palm.
Introduction to Engineering MATLAB – 9 Plotting - 2 Agenda Formatting plots.
Introduction to MATLAB ENGR 1181 MATLAB 1. MATLAB Built-in Math Functions  Pre-defined in MATLAB ready for use exp(x) – exponential (e x ) log(x) – natural.
NET 222: COMMUNICATIONS AND NETWORKS FUNDAMENTALS ( NET 222: COMMUNICATIONS AND NETWORKS FUNDAMENTALS (PRACTICAL PART) Lab 2 : potting to Matlab Networks.
CS100A, Fall 1998, Lecture 191 CS100A, Fall 1998 Lecture 19, Thursday Nov 05 Matlab Concepts: Matlab arrays Matlab subscripting Matlab plotting.
CS100A, Fall 1998, Lecture 201 CS100A, Fall 1998 Lecture 20, Tuesday Nov 10 More Matlab Concepts: plotting (cont.) 2-D arrays Control structures: while,
How to use MATLAB (using M-files) Double click this icon To start Matlab 6.5.
Creating a Plot The plot function can take one or more inputs; e.g. plot (x, y) or plot (y) Note that in the two-argument version, the vectors x and.
Linear Algebra Review.
ECE 1304 Introduction to Electrical and Computer Engineering
Plotting Chapter 5.
Introduction to MATLAB
Chapter 7 Introduction to MATLAB for Engineers, Third Edition
Course Information Do not rely on color to distinguish curves (due to black-white printout). Use different line styles to distinguish curves (solid, dashed,
Lecture 25: Exploring data
Matrices and Arrays.
Net 222: Communications and networks fundamentals (Practical Part)
Net 222: Communications and networks fundamentals (Practical Part)
Net 222: Communications and networks fundamentals (Practical Part)
MATLAB How to use (using M-files) Double click this icon
Introduction to Matlab
MATLAB How to use (using M-files) Double click this icon
Tutorial 2 SEG7550 Introduction to MATLAB II

MATLAB How to use (using M-files)
Introduction to MATLAB Plotting LAB 3
L13. More on Arrays Square Bracket Notation Subscripts
Introduction to MATLAB
Introduction to MATLAB
Yang-Ming University, Taipei, Taiwan
Matlab Intro.
Plotting Signals in MATLAB
Introduction to MATLAB
Introduction to MATLAB
Introduction to MATLAB
Announcements P3 due today
Introduction to Matlab
Math review - scalars, vectors, and matrices
Matlab Intro.
Presentation transcript:

Introduction to MATLAB Northeastern University: College of Computer and Information Science Co-op Preparation University (CPU) 10/27/2003

Overview for 10/27/2003 Brief review of topics covered in last session (10/23/2003) Plotting – in depth File I/O – in depth

Review for 10/23/2003 Functions

Sample MATLAB functions Min Max Median Mean Sum Diff

MATLAB Functions: Min Min Will find the minimum element of the array Works slightly different on vectors and matrices

MATLAB Functions: Max Max Will find the maximum element of the array Also works slightly different on vectors and matrices

MATLAB Functions: Median Will find the median value of the array Also works slightly different on vectors and matrices

MATLAB Functions: Mean Returns the average value of the array Works slightly different on vectors and matrices

MATLAB Functions: Sum Sum Will return a sum of the array elements Also works slightly different on vectors and matrices

Diff Diff Will return the difference between adjacent elements in an array This is an approximate derivative

New MATLAB Function rand() - Uniformly distributed random numbers and arrays Ex of syntax: A = rand(n) A = rand(m,n) Where m and n are dimensions of the matrix

Rand() con’t: 2 Scalars may be generated Vectors may be generated Ex. A = rand(1,1); Vectors may be generated Ex. A = rand(10,1);

Rand() con’t: 3 Generated random numbers will be between 0 and 1. Scaling can be done by multiplying the resulting matrix or vector by the number you wish to scale with

Plotting Several types of plots available Plot Polar Bar Hist

HAPPY BIRTHDAY WING Here is your pixilated birthday cake. It’s pixa-licious.

Plot() (from MATLAB help) Linear 2-D plot Syntax: plot(Y) plot(X1,Y1,...) plot(X1,Y1,LineSpec,...) plot(...,'PropertyName',PropertyValue,...) h = plot(...)

Plot() con’t: 2 MATLAB defaults to plotting a blue line between points Other options exist: Different color lines Different types of lines No line at all!

Plot() con’t: 3 – Color options Yellow - ‘y’ Magenta - ‘m’ Cyan - ‘c’ Red - ‘r’ Green - ‘g’ Blue - ‘b’ White - ‘w’ Black - ‘k’ Example: plot(temp, ‘y’);

Plot() con’t: 4 – Line options Line styles: - solid line (default) -- dashed line : dotted line -. dash-dot line

Plot() con’t: 5 – Line Markings + - plus sign o - circle * - asterisk . - Point x - cross s - square d - diamond ^ - upward pointing triangle v - downward pointing triangle > - right pointing triangle < - left pointing triangle p - five-pointed star (pentagram) h - six-pointed star (hexagram)

Polar() Plot polar coordinates Syntax: polar(theta,rho) polar(theta,rho,LineSpec) Theta – Angle counterclockwise from the 3 o’clock position Rho – Distance from the origin

Polar() con’t: 2 Line color, style and markings apply as they did in the example with Plot().

Bar() Creates a bar graph Syntax bar(Y) bar(x,Y) bar(...,width) bar(...,'style') bar(...,LineSpec)

Hist() Creates a histogram plot Syntax: n = hist(Y) n = hist(Y,x) n = hist(Y,nbins)

File I/O Both high-level and low-level file I/O High-level covered today

High-Level File I/O I/O = input/output 3 important commands for input csvread dlmread textread

csvread Read a comma-separated value file Syntax: a = csvread('filename') a = csvread('filename',row,col) a = csvread('filename',row,col,range) Note – csvread does not like to read in text!

dlmread Like csvread, only instead of a comma, you specify the delimiter Syntax: a = dlmread(filename,delimiter) a = dlmread(filename,delimiter,R,C) a = dlmread(filename,delimiter,range) Treat this like a generalized form of csvread.

textread Reads formatted data from a text file Syntax: [A,B,C,...] = textread('filename','format') [A,B,C,...] = textread('filename','format',N) [...] = textread(...,'param','value',...) Useful, but try to do without it, MATLAB is somewhat slower when dealing with text data