Introduction to MATLAB MECH 300H Spring 2008. Starting of MATLAB.

Slides:



Advertisements
Similar presentations
MATLAB – A Computational Methods By Rohit Khokher Department of Computer Science, Sharda University, Greater Noida, India MATLAB – A Computational Methods.
Advertisements

Introduction to MATLAB The language of Technical Computing.
Introduction to M ATLAB Programming Ian Brooks Institute for Climate & Atmospheric Science School of Earth & Environment
Introduction to Matlab
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.
Flow Charts, Loop Structures
Scripts and Flow Control. Scripts So far we have been entering commands directly into the command line But there is a better way Script files (and functions)
Lecture 5 Review Programming Program Structures Comparison Repetition: looping or iteration Conditional execution: branching Bubble Sort.
Introduction to MATLAB
EGR 106 – Week 2 – Arrays Definition, size, and terminology Construction methods Addressing and sub-arrays Some useful functions for arrays Character arrays.
EGR 106 – Week 2 – Arrays & Scripts Brief review of last week Arrays: – Concept – Construction – Addressing Scripts and the editor Audio arrays Textbook.
Introduction to Matlab Tutorial for CS4MN3/SE3X03 Wen Yu McMaster University.
1 Introduction to MatLab MatLab stands for Matrix Laboratory. As the name suggests most of the programming operations have as input or output a matrix.
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.
Programming For Nuclear Engineers Lecture 12 MATLAB (3) 1.
January 24, 2005 Lecture 3 - By P. Lin 1 CPET 190 Lecture 3 Problem Solving with MATLAB
259 Lecture 15 Introduction to MATLAB. 2 What is MATLAB?  MATLAB, which stands for “MATrix LABoratory” is a high- performance language for technical.
MATLAB INTRO CONTROL LAB1  The Environment  The command prompt Getting Help : e.g help sin, lookfor cos Variables Vectors, Matrices, and Linear Algebra.
Martin Ellison University of Warwick and CEPR Bank of England, December 2005 Introduction to MATLAB.
Nonparametric Econometrics1 Intro to Matlab for Data Analysis and Statistical Modeling.
Introduction to MATLAB Session 1 Prepared By: Dina El Kholy Ahmed Dalal Statistics Course – Biomedical Department -year 3.
Introduction to MATLAB January 18, 2008 Steve Gu Reference: Eta Kappa Nu, UCLA Iota Gamma Chapter, 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.
ECE 1304 Introduction to Electrical and Computer Engineering Section 1.1 Introduction to MATLAB.
A Brief Introduction to Matlab Laila Guessous Dept. of Mechanical Engineering Oakland University.
Introduction to Engineering MATLAB – 6 Script Files - 1 Agenda Script files.
MATLAB Tutorial EE 327 Signals and Systems 1. What is MATLAB? MATLAB – Matrix Laboratory The premier number-crunching software Extremely useful for signal.
INTRODUCTION TO MATLAB LAB# 01
Numerical Computation Lecture 2: Introduction to Matlab Programming United International College.
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.
Vectors and Matrices In MATLAB a vector can be defined as row vector or as a column vector. A vector of length n can be visualized as matrix of size 1xn.
Introduction to MATLAB 7 Engineering 161 Engineering Practices II Joe Mixsell Spring 2010.
10/24/20151 Chapter 2 Review: MATLAB Environment Introduction to MATLAB 7 Engineering 161.
Basics of MATLAB By DR. Wafaa Shabana
What does C store? >>A = [1 2 3] >>B = [1 1] >>[C,D]=meshgrid(A,B) c) a) d) b)
Scientific Computing Introduction to Matlab Programming.
Chapter 1 – Matlab Overview EGR1302. Desktop Command window Current Directory window Command History window Tabs to toggle between Current Directory &
Matlab Screen  Command Window  type commands  Current Directory  View folders and m-files  Workspace  View program variables  Double click on a.
Introduction to MATLAB 7 MATLAB Programming for Engineer Hassan Migdadi Spring 2013.
Lecture 20: Choosing the Right Tool for the Job. What is MATLAB? MATLAB is one of a number of commercially available, sophisticated mathematical computation.
ENG College of Engineering Engineering Education Innovation Center 1 Basic For Loops in MATLAB Programming in MATLAB / Chapter 6 Topics Covered:
Introduction to Matlab  Matlab is a software package for technical computation.  Matlab allows you to solve many numerical problems including - arrays.
Introduction to MATLAB 7 Engineering 161 Engineering Practices II Joe Mixsell Spring 2012.
Introduction to Matlab
INTRODUCTION TO MATLAB Dr. Hugh Blanton ENTC 4347.
Digital Image Processing Introduction to MATLAB. Background on MATLAB (Definition) MATLAB is a high-performance language for technical computing. The.
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 Module #10 Page 1 Introduction to Matlab Module #10 – Creating Graphical User Interfaces Topics 1.Overview of GUI Development using.
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.
Introduction to Programming on MATLAB Ecological Modeling Course Sep 11th, 2006.
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.
MAE 421 Matlab review Prof. Mark Glauser Created by: David Marr.
ECE 1304 Introduction to Electrical and Computer Engineering
Prof. Mark Glauser Created by: David Marr
Computer Application in Engineering Design
Outline Matlab tutorial How to start and exit Matlab Matlab basics.
MATLAB DENC 2533 ECADD LAB 9.
Matlab Workshop 9/22/2018.
StatLab Matlab Workshop
Use of Mathematics using Technology (Maltlab)
MATLAB Tutorial Dr. David W. Graham.
StatLab Workshop: Intro to Matlab for Data Analysis and Statistical Modeling 11/29/2018.
Lecture 2 Introduction to MATLAB
Very Old Introduction to Matlab for EGR 220
Using Script Files and Managing Data
Presentation transcript:

Introduction to MATLAB MECH 300H Spring 2008

Starting of MATLAB

MATLAB file operations use the current directory and the search path as reference points. Any file you want to run must either be in the current directory or on the search path

Arithmetic Operators MATLAB works according to the priorities: 1. quantities in brackets 2. powers, 2 + 3^2 => = * /, working left to right (3*4/5=12/5) , working left to right (3+4-5=7-5)

Number and format The ‘e’ notation is used for very large or very small numbers: The constant ‘π’ is represented by the command ‘pi’ All computations in MATLAB are done in double precision, which means about 15 significant figures. The format how MATLAB prints numbers is controlled by the ‘format’ command

Common built-in function

Suppressing input One often does not want to see the result of intermediate calculations terminate the assignment statement or expression with semicolon, ‘;’ The value of x is hidden. Note also we can place several statements on one line, separated by commas or semicolons.

M-files In writing programs, it is suggested to write it in the editor and save it in a file named, abc.m, instead of writing in the command window The Editor/Debugger provides a graphical user interface for text editing, as well as for M-file debugging. To create or edit an M-file use File -> New or File -> Open, or use the edit function

Matrix To entry a matrix: Separate the elements of a row with blanks or commas Use a semicolon ; to indicate the end of each row Surround the entire list of elements with square brackets, [ ] For example: A is created and is a 3x3 matrix

Matrix To extract a element from a matrix or to insert a element to a matrix: recall the name of matrix insert the row and column number into a bracket A ( i, j ) – i and j represent row and column no. respectively For example,

The Colon Operator Colon ‘:’ generate vector, say x, from n to m with unit increment Use increment other than one, say pi/4

Plotting graph The default is to plot solid lines. A solid white line is produced by To put a title and label the axes, we use

Plotting graph To edit the range of axis: On the figure window EDIT  Axes properties Example: First curveSecond curve

Export Figures In the figure window, one can save the current figure in many different formats, such as “tiff”, “jpg”, “eps”,”fig” MATLAB only recognizes “.fig” format.

Flow control statement The flow control statement used in MATLAB is similar to that in C/C++ language For Loops - repeats a group of statements a fixed, predetermined number of times While Loops - repeats a group of statements an indefinite number of times under control of a logical condition If -evaluates a logical expression and executes a group of statements when the expression is true

Example for Loop Plot the function MATLAB code: % N=the number of interval N=100; for i=1:N x(i)=i/N*2*pi; y(i)=sin(x(i)); end plot(x,y,'*')

Function statement Function is the statements which can be used by other programs or functions. function [] = function_name (); Example %function function [f,n] = funeval(x); n = length(x); f=sin(x).*exp(x)+ones(n,1); %The main program N= 100; dx = 10/N; for i = 1:N x = i * dx; end [f,n] = funeval(x); plot(x,f)