Lecture 2 - Matlab Introduction CVEN 302 June 5, 2002.

Slides:



Advertisements
Similar presentations
Introduction to M ATLAB Programming Ian Brooks Institute for Climate & Atmospheric Science School of Earth & Environment
Advertisements

Introduction to Engineering MATLAB – 11 Plotting - 4 Agenda Multiple curves Multiple plot.
Plotting Selim Aksoy Bilkent University Department of Computer Engineering
Introduction to Graphing Using MATLAB. Line Graphs  Useful for graphing functions  Useful for displaying data trends over time  Useful for showing.
Introduction to MATLAB for Biomedical Engineering BME 1008 Introduction to Biomedical Engineering FIU, Spring 2015 Lesson 2: Element-wise vs. matrix operations.
MATLAB – What is it? Computing environment / programming language Tool for manipulating matrices Many applications, you just need to get some numbers in.
MA/CS375 Fall MA/CS 375 Fall 2002 Lecture 4.
Intro MATLAB: Special Purpose Computer Program Optimized to perform engineering and scientific calculations Implements the MATLAB programming language.
Soft Computing 1 Matlab Tutorial Kai Goebel, Bill Cheetham RPI/GE CRD
Vectors and Plotting Selim Aksoy Bilkent University Department of Computer Engineering
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 Array The fundamental unit of data in any MATLAB program is the array. 1. An array is a collection of data values organized into rows and.
EPSII 59:006 Spring Outline Managing Your Session File Usage  Saving Workspace  Loading Data Files  Creating M-files More on Matrices Review.
Part 1 Chapter 2 MATLAB Fundamentals
MATLAB Fundamentals.
MATLAB Basics With a brief review of linear algebra by Lanyi Xu modified by D.G.E. Robertson.
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.
„  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.
1 Week 3: Vectors and Matrices (Part III) READING: 2.2 – 2.4 EECS Introduction to Computing for the Physical Sciences.
MEGN 536 – Computational Biomechanics MATLAB: Getting Started Prof. Anthony J. Petrella Computational Biomechanics Group.
ECE 1304 Introduction to Electrical and Computer Engineering Section 1.1 Introduction to MATLAB.
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.
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.
COMP 116: Introduction to Scientific Programming Lecture 5: Plotting, Scripts and publishing.
What is MATLAB? MATLAB is one of a number of commercially available, sophisticated mathematical computation tools. Others include Maple Mathematica MathCad.
Matlab Programming for Engineers Dr. Bashir NOURI Introduction to Matlab Matlab Basics Branching Statements Loops User Defined Functions Additional Data.
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.
MATLAB Environment ELEC 206 Computer Applications for Electrical Engineers Dr. Ron Hayne.
Matlab Basics FIN250f: Lecture 3 Spring 2010 Grifths Web Notes.
ES 240: Scientific and Engineering Computation. Chapter 2 Chapter 2: MATLAB Fundamentals Uchechukwu Ofoegbu Temple University.
1 DKT 211 Basic Communication Engineering LAB # 1A : (Lecture 1) Introduction to Matlab  Basic Features  Scientific features  Array Operations  Script.
INTRODUCTION TO MATLAB MATLAB is a software package for computation in engineering, science, and applied mathemat-ics. It offers a powerful programming.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Introduction to MATLAB 7 for Engineers William J. Palm.
Computer Simulation Lab Electrical and Computer Engineering Department SUNY – New Paltz SUNY-New Paltz “Lecture 2”
Part 1 Chapter 2 MATLAB Fundamentals PowerPoints organized by Dr. Michael R. Gustafson II, Duke University and Prof. Steve Chapra, Tufts University All.
Lecture 20: Choosing the Right Tool for the Job. What is MATLAB? MATLAB is one of a number of commercially available, sophisticated mathematical computation.
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  Matlab is a software package for technical computation.  Matlab allows you to solve many numerical problems including - arrays.
EGR 115 Introduction to Computing for Engineers MATLAB Basics 3: Array Operations Monday 08 Sept 2014 EGR 115 Introduction to Computing for Engineers.
INTRODUCTION TO MATLAB DAVID COOPER SUMMER Course Layout SundayMondayTuesdayWednesdayThursdayFridaySaturday 67 Intro 89 Scripts 1011 Work
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.
1 Lecture 3 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept.
1 Faculty Name Prof. A. A. Saati. 2 MATLAB Fundamentals 3 1.Reading home works ( Applied Numerical Methods )  CHAPTER 2: MATLAB Fundamentals (p.24)
Math 252: Math Modeling Eli Goldwyn Introduction to MATLAB.
CS100A, Fall 1998, Lecture 201 CS100A, Fall 1998 Lecture 20, Tuesday Nov 10 More Matlab Concepts: plotting (cont.) 2-D arrays Control structures: while,
An Introduction to Programming in Matlab Emily Blumenthal
MATLAB (Matrix Algebra laboratory), distributed by The MathWorks, is a technical computing environment for high performance numeric computation and.
1-2 What is the Matlab environment? How can you create vectors ? What does the colon : operator do? How does the use of the built-in linspace function.
Outline What is MATLAB MATLAB desktop Variables, Vectors and Matrices Matrix operations Array operations Built-in functions: Scalar, Vector, Matrix Data.
EGR 106 – Week 5 – 2-D Plots Question : Why do engineers use plots? Answer : To analyze, visualize, and present data. Matlab has many useful plotting options.
How to use MATLAB (using M-files) Double click this icon To start Matlab 6.5.
Prof. N. P. Jadhav Presented by. Overview of MATLAB environment MATLAB is an interactive, matrix-based system for scientific and engineering numeric computation.
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
Introduction to Programming for Mechanical Engineers (ME 319)
Matrices and Arrays.
Net 222: Communications and networks fundamentals (Practical Part)
MATLAB How to use (using M-files) Double click this icon
MATLAB How to use (using M-files) Double click this icon
MATLAB How to use (using M-files)
INTRODUCTION TO MATLAB
Plotting Signals in MATLAB
Matlab Basics Tutorial
Presentation transcript:

Lecture 2 - Matlab Introduction CVEN 302 June 5, 2002

Lecture Goals Vectors Operations Matrix Operations Plot & Graphics Matlab files Matlab controls

Vector A vector is defined as a combination of variables values to with components of x j, where j = 1,…n values.

Vectors Matlab is designed for vector and matrix manipulation some of the basic commands are given as

Vectors t’ represents the transpose of the vector “t”. Individual components can be represented by t = [ 4,5,6,9], where t(3) = 6. [ ] represent the start and finish of the vector and/or matrix. ( ) represent components of the vector. A period “.” represent an elemental set of functions, such as multiplication, division,etc.

Vector element Operations Individual addition A + BA + B Individual subtractionA – BA - B Individual multiplicationA*BA.*B Individual division (left)A/BA./B Individual division (right) A\BA.\B Individual powerA B A.^B

Hierarchy of the vector operations Precedence ( 1 ) - Parenthesis ( 2 )- Exponential from left to right ( 3 )- Multiplication and division from left to right. ( 4 )- Addition and subtraction from left to right.

Vector Operations Vector product - A is 1 x n vector The magnitude of the vector is a dot product of the vector.

Vector Examples

Matrix A matrix is a two dimensional arrays, where the matrix B is represented by a [ m x n ]

Matrix Operations For addition and subtraction, the matrix sizes must match up. If you are adding to each component of the matrix you can do a simple scalar addition. Examples: [A] + [B] = [C] [A] + 3 = [D]

Matrix Operation Multiplication of matrices will need to match up the columns to the row values of the following matrix. Scalar multiplication will work. Division is different. You will either divide member by member, where the matrices are the same size or you will need to find the inverse of the matrix.

Matrix Multiplication Examples

Graphical Representation Matlab has a function known as “plot( ), where the values are plotted on an x-y plane. General format of the graph is given as, plot(x,y,’symbols’) The symbols represent the color, point shape, and the line type.

Plot symbols commands ColorsSymbols Lines y – yellow. – point- – solid line m – mago – circle: – dots c – cyanx – xmark-. – line dot r – red+ – plus- - – dashes g – green* – star b – blues – square w – whited – diamond k – blackv – triangle down ^ – triangle up < – left < – right p – pentagram h – hexagram

Plot Commands t = linspace(0, 2*pi); - results in 100 data points y1 = cos(t);- cosine of the points y2 = sin(t);- sine of the points y3 = y1.*y2;- cos(t)*sin(t) plot(t,y1,’-’);- plots cosine verse t with a straight line. plot(t,y3,’r:’)- plots cosine*sine verse t with red dots.

Plot Commands Example: plot(t,y1,’-’,t,y2,’g*’,t,y3,’r-.’) - plots all 3 axis( [0 2*pi ]) - adds axes legend(‘cos(t)’,’sin(t)’,’cos(t)*sin(t)’) - legend Note that the [ ] represent an array and ( ) represent a function, and ‘ ‘ represent the symbols.

Matlab commands for file management The files can be written as a script, which can be loaded into the memory. From the command line: “echo” - causes the file to be echoed to the screen. “what” - shows the type of file in the current directory. “type” - will present show the file contents

Matlab Files There are three types of files: Data files –Matlab files have their own format for saving data –ascii files are standard text files, which can be printed out or used in excel files. m-files represent the program files. function files are functions similar to ‘sin(x)’, cos(x), etc.

Data Files Data files can be written in two forms: Matlab format ascii format

Matlab data format MatLab generates a data file, which will have look like: “filename”.mat File can be loaded into the memory with: load “filename” t = linspace(0, 2*pi) x = cos(t) save data1 t x clear what data1.mat load data1

ACSII format An ascii file type can be created by adding a flag on the end of the save command save “filename”.dat -ascii t = linspace(0 2*pi) x = sin(t) save data2.dat t x -ascii dir data2.dat clear load data2.dat -ascii

Loading Data Files Matlab Files load “filename” The file will load the file into the same format as it was saved. ASCII Files load “filename.dat” -ascii The file will be loaded as an data array and will require you to modify to obtained the data vectors.

Data file example t=linspace(0,2*pi); y1 = sin(x); save data1 t y1; clear (created data1.mat and will show up in home directory.) load data1; (data1 will have created t and y1 vectors.) save data2.dat t y1 -ascii clear (created a ascii file with the data) load data2 -ascii

Data file example continued (loaded an ascii file into memory as data2 array) whos data2 2X100 double array t= data2(1,:); y1= data2(2,:); : assigns the row to the vector

Homework Check the Homework files –create a data file –input a simple program –run the program –plot the results