Matlab Tutorial (material available at 1 Dr. Jim Martin Associate Professor School of Computing.

Slides:



Advertisements
Similar presentations
Introduction to MATLAB The language of Technical Computing.
Advertisements

Introduction to Matlab
Introduction to Matlab Workshop Matthew Johnson, Economics October 17, /13/20151.
Data Analytics and Dynamic Languages Lee E. Edlefsen, Ph.D. VP of Engineering 1.
CIS 101: Computer Programming and Problem Solving Lecture 8 Usman Roshan Department of Computer Science NJIT.
Introduction to Matlab By: Dr. Maher O. EL-Ghossain.
Getting started with Matlab Numerical Methods Appendix B help/techdoc/learn_matlab/learn_matlab.html.
Introduction to Matlab Οικονομίδης Δημήτρης
Digital Image Processing Lecture3: Introduction to MATLAB.
Lecture 1: Introduction Lecture series based on the text: Essential MATLAB for Engineers and Scientists By Hahn & Valentine
259 Lecture 15 Introduction to MATLAB. 2 What is MATLAB?  MATLAB, which stands for “MATrix LABoratory” is a high- performance language for technical.
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
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.
CIS 601 MATLAB First Impressions. MATLAB This introduction will give Some basic ideas Main advantages and drawbacks compared to other languages.
Introduction to MATLAB adapted from Dr. Rolf Lakaemper.
Introduction to MATLAB Session 1 Prepared By: Dina El Kholy Ahmed Dalal Statistics Course – Biomedical Department -year 3.
You can make this in matlab!. Matlab Introduction and Matrices.
Introduction to M ATLAB EE 100 – EE Dept. - JUST.
Introduction to Matlab 1. Outline: What is Matlab? Matlab Screen Variables, array, matrix, indexing Operators Plotting Flow Control Using of M-File Writing.
Eng Advanced Marine Vehicles Todays agenda: Lab tomorrow at 2pm (structures lab) ‏ Advanced Marine Party 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.
A L I MAM M OHAMMAD B IN S AUD I SLAMIC U NIVERSITY C OLLEGE OF S CIENCES D EPARTMENT OF M ATHEMATICS MATLAB 251 : MATH SOFTWARE Introduction to MATLAB.
1 Lab of COMP 406 Teaching Assistant: Pei-Yuan Zhou Contact: Lab 1: 12 Sep., 2014 Introduction of Matlab (I)
Yasser F. O. Mohammad Approximations and Round-off Errors.
Computational Methods of Scientific Programming Lecturers Thomas A Herring, Room A, Chris Hill, Room ,
Piotr Wolski Introduction to R. Topics What is R? Sample session How to install R? Minimum you have to know to work in R Data objects in R and how to.
Eng Ship Structures 1 Introduction to Matlab.
INTRODUCTION TO MATLAB LAB# 01
1 Computer Programming (ECGD2102 ) Using MATLAB Instructor: Eng. Eman Al.Swaity Lecture (1): Introduction.
Getting Started with MATLAB 1. Fundamentals of MATLAB 2. Different Windows of MATLAB 1.
Basics of MATLAB By DR. Wafaa Shabana
Matlab The language of Technical computing Mr. D. Suresh Assistant Professor, Dept. of CSE, PSNA CET, Dindigul.
Matlab 14.html Cost: $100 Available in labs on Windows and Unix machines.
Introduction to Matlab
Introduction to MATLAB adapted from Dr. Rolf Lakaemper.
Introduction to Matlab. Outline:  What is Matlab? Matlab Screen Variables, array, matrix, indexing Operators (Arithmetic, relational, logical ) Display.
Introduction to Matlab. What is Matlab? A software environment for interactive numerical computations Examples:  Matrix computations and linear algebra.
Matlab Screen  Command Window  type commands  Current Directory  View folders and m-files  Workspace  View program variables  Double click on a.
Matlab Tutorial (material available at 1 Dr. Jim Martin Associate Professor School of Computing.
MATLAB Tutorial EE313 Signals and Systems Created: Thursday Jan 25, 2007 Rayyan Jaber Modified by: Jeff Andrews.
CIS 595 MATLAB First Impressions. MATLAB This introduction will give Some basic ideas Main advantages and drawbacks compared to other languages.
Introduction to Matlab
CIS 601 Fall 2003 Introduction to MATLAB Longin Jan Latecki Based on the lectures of Rolf Lakaemper and David Young.
Introduction to Matlab Patrice Koehl Department of Biological Sciences National University of Singapore
CSE 455 : Computer Vision MATLAB 101 Getting Started with MATLAB.
Math 252: Math Modeling Eli Goldwyn Introduction to MATLAB.
CIS 595 MATLAB First Impressions. MATLAB This introduction will give Some basic ideas Main advantages and drawbacks compared to other languages.
Introduction to Matlab Engr. Mian Shahzad Iqbal LAB NO.2
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 Introduction to Matlab. 2 What is Matlab? Matlab is basically a high level language which has many specialized toolboxes for making things easier for.
Introduction to Matlab. Outline:  What is Matlab? Matlab Screen Variables, array, matrix, indexing Operators.
Matlab.
Introduction to MATLAB
Lecture: MATLAB Chapter 1 Introduction
INTRODUCTION TO BASIC MATLAB
MATLAB DENC 2533 ECADD LAB 9.
Introduction to Matlab
Matlab Workshop 9/22/2018.
Introduction to MATLAB
StatLab Matlab Workshop
Digital Image Processing using MATLAB
Part I – Matlab Basics.
StatLab Workshop: Intro to Matlab for Data Analysis and Statistical Modeling 11/29/2018.
Digital Image Processing
CSE 307 Basics of Image Processing
Matlab Basic Dr. Imtiaz Hussain
Simulation And Modeling
Presentation transcript:

Matlab Tutorial (material available at 1 Dr. Jim Martin Associate Professor School of Computing Clemson University Networking Lab’s Website: Don’t worry Homer, the guys/girls in the Networking Lab will fix things!! WooHoo….I don’t know what this means There are no more /8 TCP/IP V4 Addresses!!

2 Objective is to give you some hands on experience with using Matlab for data analysis Matlab Tutorial: Overview

Matlab Overview 3 What Is MATLAB? MATLAB (MATrix LABoratory) high-performance language for technical computing computation, visualization, and programming in an easy-to-use environment Typical uses include: Math and computation Algorithm development Modelling, simulation, and prototyping Data analysis, exploration, and visualization Scientific and engineering graphics Application development, including Graphical User Interface building

What is Matlab? Matlab is basically a high level language which has many specialized toolboxes for making things easier for us How high? Assembly High Level Languages such as C, Pascal etc. Matlab

Matlab Intro 5 A good choice for vision program development because: Easy to do very rapid prototyping Quick to learn, and good documentation A good library of image processing functions Excellent display capabilities Widely used for teaching and research in universities and industry Another language to impress your boss with !

Matlab Intro 6 Has some drawbacks: Slow for some kinds of processes Not geared to the web Not designed for large-scale system development

Matlab Intro 7 MATLAB consists of: The MATLAB language a high-level matrix/array language with control flow statements, functions, data structures, input/output, and object-oriented programming features. The MATLAB working environment the set of tools and facilities that you work with as the MATLAB user or programmer, including tools for developing, managing, debugging, and profiling Handle Graphics the MATLAB graphics system. It includes high-level commands for two-dimensional and three-dimensional data visualization, image processing, animation, and presentation graphics. …(cont’d)

Matlab Intro 8 … The MATLAB function library. a vast collection of computational algorithms ranging from elementary functions like sum, sine, cosine, and complex arithmetic, to more sophisticated functions like matrix inverse, matrix eigenvalues, Bessel functions, and fast Fourier transforms as well as special image processing related functions The MATLAB Application Program Interface (API) a library that allows you to write C and Fortran programs that interact with MATLAB. It include facilities for calling routines from MATLAB (dynamic linking), calling MATLAB as a computational engine, and for reading and writing MAT-files.

Matlab Intro 9 Some facts for a first impression Everything in MATLAB is a matrix ! MATLAB is an interpreted language, no compilation needed (but possible) MATLAB does not need any variable declarations, no dimension statements, has no packaging, no storage allocation, no pointers Programs can be run step by step, with full access to all variables, functions etc.

Matlab Screen Command Window –type commands Current Directory –View folders and m-files Workspace –View program variables –Double click on a variable to see it in the Array Editor Command History –view past commands –save a whole session using diary

Variables No need for types. i.e., All variables are created with double precision unless specified and they are matrices. After these statements, the variables are 1x1 matrices with double precision int a; double b; float c; Example: >>x=5; >>x1=2;

Array, Matrix a vector x = [ ] x = a matrix x = [1 2 3; 5 1 4; ] x =

Long Array, Matrix t =1:10 t = k =2:-0.5:-1 k = B = [1:4; 5:8] x =

Generating Vectors from functions zeros(M,N)MxN matrix of zeros ones(M,N)MxN matrix of ones rand(M,N)MxN matrix of uniformly distributed random numbers on (0,1) x = zeros(1,3) x = x = ones(1,3) x = x = rand(1,3) x =

Matrix Index The matrix indices begin from 1 (not 0 (as in C)) The matrix indices must be positive integer Given: A(-2), A(0) Error: ??? Subscript indices must either be real positive integers or logicals. A(4,2) Error: ??? Index exceeds matrix dimensions.

Concatenation of Matrices x = [1 2], y = [4 5], z=[ 0 0] A = [ x y] B = [x ; y] C = [x y ;z] Error: ??? Error using ==> vertcat CAT arguments dimensions are not consistent.

Operators (arithmetic) +addition -subtraction *multiplication /division ^power ‘complex conjugate transpose

Exercise Create a 4x4 matrix that contains random numbers Look up help for the random number generator (help rand) 18

Exercise Create a 4x4 matrix that contains random numbers Look up help for the random number generator (help rand) x=[rand(1,4);rand(1,4);rand(1,4);rand(1,4)] 19

Example Plot X=rand(1,100) ;creates 100 RNs Y=(2*x) + 2 Plot(x,y) 20

Random Numbers How can you tell if a random number generator is good? Properties of a U(0,1) RN Generator: –Uniformly distributed in the interval (0,1) –The RNs should be independent…i.e., uncorrelated –Many RNs should be generated before the cycle repeats (ideally it exhibits full period) –Reproducible and allow multiple streams –Consumes minimal cpu and memory resources Technique: plot sequential random numbers from the generator…. –X=rand(1,1000); –Y=rand(1,1000); –Plot(x,y) ?? –Try a scatter plot instead…(help scatter) 21

Random Numbers Technique: plot sequential random numbers from the generator…. –X=rand(1,1000); –Y=rand(1,1000); –Plot(x,y) ?? –Try a scatter plot instead…(help scatter) 22

23 A time series is a sequence of observations taken sequentially in time. Typically the observations are dependent Time series analysis is concerned with techniques for the analysis of this dependence. A time series Z1 … Zn of n successive observations can be regarded as a sample realization from an infinite population of such time series that could have been generated by a stochastic process. A model that describes the probability structure of a sequence of observations is called a stochastic process. A special class of stochastic processes called stationary processes assumes the process is in a particular state of statistical equilibrium. i.e., the statistical properties are unaffected by time. Time Series Analysis

24 >> load dataset1.dat >> mySize=size(dataset1) mySize = If we issue ‘mean dataset1’, should see ans = Sample Mean in Matlab

25 Look at a Matlab program that reads a data file (call it ping.dat, contains ping RTT samples in milliseconds) : First, let’s compute the sample mean without using the mean function. Second, let’s plot the PDF Probability Distributions

26 function mySampleMean() load dataset1.dat sampleSize = size(dataset1); numberSamples = sampleSize(1); totalThroughputCount = 0; averageThroughput = 0.0; for i = 1 : numberSamples totalThroughputCount = totalThroughputCount + dataset1(i,2); end averageThroughput= totalThroughputCount / numberSamples; fprintf(1,'mySampleMean: NumberSamples: %d, sample Throughput: %12.0f \n',numberSamples,averageThroughput); return; Example computing sample mean

27 Using the same dataset, input the following to plot the PDF of the timeseries load dataset1.dat myData=dataset1(:,2); myDataSize=size(dataset1) [N,X] = hist(myData,100); N=N/myDataSize(1); bar(X,N); axis([0 max(myData) ]); hold on ylabel('PDF') xlabel('Distribution Values') title('distribution PDF') grid Plotting the Distribution (pdf)

28 See plotPDF.m load ping.dat myData=ping(:,2); myDataSize=size(dataset1) [N,X] = hist(myData,100); N=N/myDataSize(1); bar(X,N); hold on ylabel(‘probability density') xlabel(Values') title(‘PDF’') grid Plotting the Distribution (pdf)