Matlab Introduction  Getting Around Matlab  Matrix Operations  Drawing Graphs  Calculating Statistics  (How to read data)

Slides:



Advertisements
Similar presentations
StatLab Workshop Yale University Maximiliano Appendino, Economics October 18 th, 2013.
Advertisements

Introduction to M ATLAB Programming Ian Brooks Institute for Climate & Atmospheric Science School of Earth & Environment
Statistical Methods Lynne Stokes Department of Statistical Science Lecture 7: Introduction to SAS Programming Language.
1 EMT 101 – Engineering Programming Dr. Farzad Ismail School of Aerospace Engineering Universiti Sains Malaysia Nibong Tebal Pulau Pinang Week 10.
Introduction to Matlab Workshop Matthew Johnson, Economics October 17, /13/20151.
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.
Introduction to MATLAB Simon O’Keefe Non-Standard Computation Group
EGR 106 – Week 2 – Arrays & Scripts Brief review of last week Arrays: – Concept – Construction – Addressing Scripts and the editor Audio arrays Textbook.
Basic Mathematics for Portfolio Management. Statistics Variables x, y, z Constants a, b Observations {x n, y n |n=1,…N} Mean.
Dr. Jie Zou PHY Welcome to PHY 3320 Computational Methods in Physics and Engineering.
Matrix Mathematics in MATLAB and Excel
Introduction to Matlab Jianguo Wang CSSCR September 2009.
Introduction to MATLAB ENGR 1187 MATLAB 1. Programming In The Real World Programming is a powerful tool for solving problems in every day industry settings.
EPSII 59:006 Spring Outline Managing Your Session File Usage  Saving Workspace  Loading Data Files  Creating M-files More on Matrices Review.
January 24, 2005 Lecture 3 - By P. Lin 1 CPET 190 Lecture 3 Problem Solving with MATLAB
Mathcad Variable Names A string of characters (including numbers and some “special” characters (e.g. #, %, _, and a few more) Cannot start with a number.
MATLAB Lecture One Monday 4 July Matlab Melvyn Sim Department of Decision Sciences NUS Business School
Matlab tutorial course Lesson 2: Arrays and data types
MATLAB INTRO CONTROL LAB1  The Environment  The command prompt Getting Help : e.g help sin, lookfor cos Variables Vectors, Matrices, and Linear Algebra.
FOR 520: Geospatial data analysis with 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,
Carolina Environmental Program UNC Chapel Hill The Analysis Engine – A New Tool for Model Evaluation, Sensitivity and Uncertainty Analysis, and more… Alison.
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.
1 Lab of COMP 406 Teaching Assistant: Pei-Yuan Zhou Contact: Lab 1: 12 Sep., 2014 Introduction of Matlab (I)
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 MATLAB LAB# 01
What is MATLAB? MATLAB is one of a number of commercially available, sophisticated mathematical computation tools. Others include Maple Mathematica MathCad.
Introduction to Matlab Module #2 Page 1 Introduction to Matlab Module #2 – Arrays Topics 1.Numeric arrays (creation, addressing, sizes) 2.Element-by-Element.
10/24/20151 Chapter 2 Review: MATLAB Environment Introduction to MATLAB 7 Engineering 161.
Getting Started with TI-Interactive. TI-Interactive TI-Interactive can be used to create a variety of graphs. Scatter Plots, Line Plots, Histograms, Modified.
MATLAB Environment ELEC 206 Computer Applications for Electrical Engineers Dr. Ron Hayne.
Lecture 2 - Matlab Introduction CVEN 302 June 5, 2002.
Matlab 14.html Cost: $100 Available in labs on Windows and Unix machines.
Introduction to MATLAB ENGR 1181 MATLAB 1. Opening MATLAB  Students, please open MATLAB now.  CLICK on the shortcut icon → Alternatively, select… start/All.
Chapter 3 MATLAB Fundamentals Introduction to MATLAB Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Chapter 1 – Matlab Overview EGR1302. Desktop Command window Current Directory window Command History window Tabs to toggle between Current Directory &
INTRODUCTION TO MATLAB MATLAB is a software package for computation in engineering, science, and applied mathemat-ics. It offers a powerful programming.
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.
Introduction to Matlab  Matlab is a software package for technical computation.  Matlab allows you to solve many numerical problems including - arrays.
Introduction to MATLAB Zongqiang Liao Research Computing Group UNC-Chapel Hill.
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.
CSE 455 : Computer Vision MATLAB 101 Getting Started with MATLAB.
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.
ECE 1304 Introduction to Electrical and Computer Engineering
Introduction to Matlab
Release Numbers MATLAB is updated regularly
Lecture 25.
MATLAB DENC 2533 ECADD LAB 9.
Matlab Workshop 9/22/2018.
EEE 244 Numerical Methods In Electrical Engineering
StatLab Matlab Workshop
MATH 493 Introduction to MATLAB
Use of Mathematics using Technology (Maltlab)
StatLab Workshop: Intro to Matlab for Data Analysis and Statistical Modeling 11/29/2018.
Lecture 2 Introduction to MATLAB
Communication and Coding Theory Lab(CS491)
Introduction to MATLAB
Demo of Basic Matlab Features
Amos Introduction In this tutorial, you will be briefly introduced to the student version of the SEM software known as Amos. You should download the current.
Presentation transcript:

Matlab Introduction  Getting Around Matlab  Matrix Operations  Drawing Graphs  Calculating Statistics  (How to read data)

Interface with Mathlab 2012  Command window Only >> line is active, the other lines only remind which previous commands you used NB Matlab does not manipulate symbols; only numbers  Command history window Double click on command to repeat previous command Single click to copy into command window and then modify  Workspace: list of created vectors & matrices  Current Folder Where to up-load files into Matlab (use load command to bring in variables from disk)

Matlab Introduction  Getting Around Matlab  Matrix Operations  Drawing Graphs  Calculating Statistics  (How to read data)

Creating A Matrix A = [1 2 0; ; ]semicolon starts new row B = [3,4,5]create row vector: “ ” (space) or “,” (comma) separates elements C = [A;B]put row vector B as new row in A D = [A,B’]put new column B in matrix A B is now transposed (single quote) E = eye(5)create 5 x 5 identity matrix F = ones(2,3)create 2 row x 3 col matrix of 1s clear C, D, Eerases matrix (or you can over-write it)

Matrix Operations B = A’transpose matrix A C = A + 3 * B D = A * B E = A.* Belement by element multiplication F = A^2multiply matrix A by itself G = A.^2raise each A element to 2 nd power X = inv(A)form inverse of matrix format(controls format of numeric values) format short g

Useful Matrix Functions det(A)gives determinant rank(A)gives rank trace(A)gives trace eig(A)gives eigenvalues For complete list, see help -> matlab -> mathematics -> matrices and linear algebra -> function summary

Matlab Introduction  Getting Around Matlab  Matrix Operations  Drawing Graphs  Calculating Statistics  (How to read data)

Drawing graph (traditional method) x = [-10 : 0.1 : 10];create row vector from -10 to +10 in increments of 1/10 To avoid an input echo, use “;” at end of command y = 3*x.^2 – 5*x + 6; plot(x,y)displays graph of x and y grid ondisplays reference lines

Graphs in 3 Dimensions [x, y] = meshgrid(-3:0.02:3, -5:0.02:5); Creates matrix of x between -3 & 3 and y between -5 & 5 in 0.02 increments to graph z in 3 rd dimension z = x.*y.^2create function of x and y plot3(x,y,z) To change the perspective use the “Rotate 3D” icon on the menu

A graph with a message !!  [x, y] = meshgrid(-3:.02:3, -5:.02:5);  z = max(0.0003, min(.0004, exp(- 3.*(((0.5+x).^2)+(y.^2)/2)) + exp((-x.^2-(y.^2)/2)).* cos(4.*x) ) );  plot3(x,y,z) To change the perspective use the “Rotate 3D” icon on the menu  340/don-t-make-me-do-this-the-equations-screamed

Other Example Graphs T=R.^2+R.*S+2.*S.^2+3;a bowl plot3(R,S,T) T=-R.^2-S.^2+6.*R+2.*S;a dome plot3(R,S,T) T=R.^3-R.*S+S.^3a beach towel on a hill

Interactive Finishing Touches  use “plottools”  Add labels, titles, change perspective, etc.  see help -> matlab -> graphics -> plots and plotting tools -> “interactive plot creation with plot tools demo”

Matlab Introduction  Getting Around Matlab  Matrix Operations  Drawing Graphs  Calculating Statistics  (How to read data)

Calculating Statistics – a traditional way Z = beta(1:end,3); mean(Z) median(Z) min(Z) max(Z) std(Z)standard deviation cov(Z) hist(Z,20)draws histogram with 20 categories

Matlab Introduction  Getting Around Matlab  Matrix Operations  Drawing Graphs  Calculating Statistics  (How to read data)

Working with files – a traditional way Cd(‘w:\’)change directory to W disk The file named col2row.prn was saved in excel file using “save as” menu with file delimited by spaces It contains three rows of numbers: F = load(‘col2row.prn');looks for spaces or columns Or G = dlmread(‘col2row.prn’,’\t’);the “\t” looks for tab- delimited

Reading a data file – an interactive mode Choose “import data” from file menu. Select file “beta” to import from Format short g (so data looks non-zero) X = beta(1:end,1)declare X is beta’s 1 st column Y = beta(1:end,2)declare Y as beta’s 2 nd column Scatter(X,Y)shows X vs. Y Regress(Y,X)best-fit slope (Y ind, X dep)

Regression – Manual Method n = size(X,1); X = [ones(n,1),X];puts new col of 1s as 1 st col in new X matrix slop = inv(X’*X)*X’*Ycalculates slope eps = Y – X*slop;calculates error from line sigma = eps’*eps/n; slop_var = sigma*inv(X’*X)covariance matrix