Introduction to Matlab Jianguo Wang CSSCR September 2009.

Slides:



Advertisements
Similar presentations
Introduction to Matlab
Advertisements

Lab # 03- SS Basic Graphic Commands. Lab Objectives: To understand M-files principle. To plot multiple plots on a single graph. To use different parameters.
MATLAB – A Computational Methods By Rohit Khokher Department of Computer Science, Sharda University, Greater Noida, India MATLAB – A Computational Methods.
Introduction to MATLAB The language of Technical Computing.
Introduction to Matlab
Introduction to Matlab Workshop Matthew Johnson, Economics October 17, /13/20151.
Matrix Manipulation and 2D Plotting
Introduction to Matlab EE 2303 Lab. MATLAB stands for “Matrix Laboratory” APPLICATIONS OF MATLAB:  Mathematical Calculations  Data Analysis & Visualization.
MATLAB’s extensive, device-independent plotting capabilities are one of its most powerful features. They make it very easy to plot any data at any time.
Introduction to Matlab. I use Matlab for: Data analysis Data plotting Image Analysis Also – Simulations (solving odes/pdes/finite element methods) – Minimisations,
Lecture 5 Review Programming Program Structures Comparison Repetition: looping or iteration Conditional execution: branching Bubble Sort.
Introduction to Matlab Tutorial for CS4MN3/SE3X03 Wen Yu McMaster University.
Introduction to Matlab 332:202 Discrete Mathematics Spring 2007.
Dr. Jie Zou PHY Welcome to PHY 3320 Computational Methods in Physics and Engineering.
Introduction to MATLAB MECH 300H Spring Starting of MATLAB.
Basis of Mathematical Modeling LECTURE 1 Computation and visualization in MATLAB Dr. N.K. Sakhnenko, PhD, Professor Associate.
MATLAB Fundamentals.
MATLAB INTRO CONTROL LAB1  The Environment  The command prompt Getting Help : e.g help sin, lookfor cos Variables Vectors, Matrices, and Linear Algebra.
1 Statistical Computing in MATLAB AMS 597 Ling Leng.
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 adapted from Dr. Rolf Lakaemper.
You can make this in matlab!. Matlab Introduction and Matrices.
ELG 3120 Signal and System Analysis 1 Introduction to MATLAB TAs Wei Zhang Ozgur Ekici (Section A)(Section B) ELG 3120 Lab Tutorial 1.
A brief introduction to MATLAB for students of Science, Engineering and Mathematics Jorge Lemagne Bindura University.
ECE 1304 Introduction to Electrical and Computer Engineering Section 1.1 Introduction to MATLAB.
INTRODUCTION TO MATLAB LAB# 01
1 Computer Programming (ECGD2102 ) Using MATLAB Instructor: Eng. Eman Al.Swaity Lecture (1): Introduction.
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.
MATLAB Harri Saarnisaari, Part of Simulations and Tools for Telecommunication Course.
Basics of MATLAB By DR. Wafaa Shabana
Matlab 14.html Cost: $100 Available in labs on Windows and Unix machines.
Introduction MATLAB stands for MATrix LABoratory.  Basics  Matrix Manipulations  MATLAB Programming  Graphics  Image types  Image Processing  Useful.
Introduction to MATLAB adapted from Dr. Rolf Lakaemper.
ES 240: Scientific and Engineering Computation. Chapter 2 Chapter 2: MATLAB Fundamentals Uchechukwu Ofoegbu Temple University.
Chapter 6 Review: User Defined Functions Introduction to MATLAB 7 Engineering 161.
Matlab Screen  Command Window  type commands  Current Directory  View folders and m-files  Workspace  View program variables  Double click on a.
Part 1 Chapter 2 MATLAB Fundamentals PowerPoints organized by Dr. Michael R. Gustafson II, Duke University and Prof. Steve Chapra, Tufts University All.
MATLAB – PT1 The purpose of this workshop is to get you started and to have fun with MATLAB! Let’s talk a little and decide on what we will be covering.
Lecture 20: Choosing the Right Tool for the Job. What is MATLAB? MATLAB is one of a number of commercially available, sophisticated mathematical computation.
Sept. 26, 2005 Lecture 6 - By Paul Lin 1 CPET 190 Lecture 6 Problem Solving with MATLAB
Introduction to Matlab  Matlab is a software package for technical computation.  Matlab allows you to solve many numerical problems including - arrays.
Introduction to Matlab
ELG 3120 Lab 2 TAs Wei Zhang Ozgur Ekici (Section A) (Section B)
Introduction to MATLAB Zongqiang Liao Research Computing Group UNC-Chapel Hill.
1 Faculty Name Prof. A. A. Saati. 2 MATLAB Fundamentals 3 1.Reading home works ( Applied Numerical Methods )  CHAPTER 2: MATLAB Fundamentals (p.24)
Introduction to Programming on MATLAB Ecological Modeling Course Sep 11th, 2006.
Introduction to Matlab Engr. Mian Shahzad Iqbal LAB NO.2
“Moh’d Sami” AshhabSummer 2008University of Jordan MATLAB By (Mohammed Sami) Ashhab University of Jordan Summer 2008.
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.
How to use MATLAB (using M-files) Double click this icon To start Matlab 6.5.
ECE 1304 Introduction to Electrical and Computer Engineering
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.
Computer Application in Engineering Design
Signals in Matlab Matlab as a name stands for Matrix Laboratory.
Introduction to Mat lab
3D-Graphs A 3D surface is defined as: z = f(x, y)
Lecture 25.
Statistical Computing in MATLAB
Ch3 Graphics Overview of Plotting Editing Plots
MATLAB DENC 2533 ECADD LAB 9.
Introduction to Matlab
(Mohammed Sami) Ashhab
Matlab Workshop 9/22/2018.
StatLab Matlab Workshop
StatLab Workshop: Intro to Matlab for Data Analysis and Statistical Modeling 11/29/2018.
Introduction to Matlab
MATLAB stands for MATrix LABoratory.
Presentation transcript:

Introduction to Matlab Jianguo Wang CSSCR September 2009

MATLAB stands for Matrix Laboratory. A complete programming environment as R, many functions and toolboxes with various applications Designed for technical computing problems, strong in matrix and vector formulas

Fast in numerical computation, basically not a symbolic solver like Maple or Mathematica Friendly programming environment, errors are easier to find and fix object-oriented elements

Why Matlab? Can we just use Excel, Eviews or SPSS? “The economics profession …... clad in impressive-looking mathematics…… gussied up with fancy equations.” Paul Krugmann 2009

Matlab Windows

Matrices and Arrays Best way to get started with MATLAB is to learn how to handle matrices in it. A = [ ; ; ; ] The basic way data and information handled in Matlab

MATLAB displays the matrix you just entered: A = Once you have entered the matrix, it is automatically remembered in the MATLAB workspace. You can simply refer to it as A. Keep in mind, variable names are case-sensitive

When you do not specify an output variable, MATLAB uses the variable ans, short for answer, to store the results of a calculation. Subscripts The element in row i and column j of A is given by A(i,j). So to compute the sum of the elements in the fourth column of A, we have: A(1,4) + A(2,4) + A(3,4) + A(4,4) Which produces: ans = 34

The Colon Operator For example: 1:10 is a row vector containing the integers from 1 to 10: To obtain non-unit spacing, specify an increment. For example: 100:-7:50 will give you Subscript expressions involving colons refer to portions of a matrix. For example: A(1:k,j) refers to the first k elements of the jth column of A.

M-Files You can create your own programs using M-files, which are plain text files containing MATLAB code. Use the MATLAB Editor or another text editor to create a file containing the same statements you would type at the MATLAB command line. Save the file under a name that ends in.m

Using M files

Multivariate Data MATLAB uses column-oriented analysis for multivariate statistical data. Each column in a data set represents a variable and each row an observation. The (i,j)th element is the ith observation of the jth variable. As an example, consider a data set with three variables: Heart rate Weight Hours exercise per week For five observations, the resulting matrix might look like D = [ ]

Now you can apply MATLAB analysis functions to this data set. For example, to obtain the mean and standard deviation of each column, use mu = mean(D), sigma = std(D) mu = sigma = Entering Long Statements s = 1 -1/2 + 1/3 -1/4 + 1/5 - 1/6 + 1/ /8 + 1/9 - 1/10 + 1/11 - 1/12;

Graphics Interactive tools enable you to manipulate graphs to achieve results that reveal the most information about your data. You can also edit and print graphs for presentations, or export graphs to standard graphics formats for presentation in Web browsers or other media.

Basic Plotting Functions plot(x,y) produces a graph of y versus x You can also label the axes and add a title, using the ‘xlabel’, ‘ylabel’, and ‘title’ functions. Example: xlabel('x = 0:2\pi') ylabel('Sine of x') title('Plot of the Sine Function','FontSize',12)

Plotting Multiple Data Sets in One Graph x = 0:pi/100:2*pi; y = sin(x); y2 = sin(x-.25); y3 = sin(x-.5); plot(x,y,x,y2,x,y3)

Specifying Line Styles and Colors It is possible to specify color, line styles, and markers (such as plus signs or circles) when you plot your data using the plot command: plot(x,y,'color_style_marker') e.g. plot(x,y,'r:+') plots a red-dotted line and places plus sign markers at each data point.

Displaying Multiple Plots in One Figure subplot(m,n,p) This splits the figure window into an m-by-n matrix of small subplots and selects the pth subplot for the current plot. Example: t = 0:pi/10:2*pi; [X,Y,Z] = cylinder(4*cos(t)); subplot(2,2,1); mesh(X) subplot(2,2,2); mesh(Y) subplot(2,2,3); mesh(Z) subplot(2,2,4); mesh(X,Y,Z)

Multimedia Read movie, in many different format e.g. function mmreader(‘filename’) Create and play movie

Further resources For lots more such like toolboxes Mathworks htttp:// logo&s_cid=docframe_homepage htttp:// logo&s_cid=docframe_homepage

Matlab in Economics tware.html#softwareM tware.html#softwareM