Introduction to MATLAB
|
|
- Clare Weaver
- 5 years ago
- Views:
Transcription
1 Introduction to MATLAB An introductory guide to using MATLAB. By following this labsheet you should be able to quickly pick up the basics of the language for use in the following lab sessions. MATLAB and a variety of toolboxes are installed on university networked machines. For use off campus you will need to register an account with your university on the Mathworks website and the COSIT group to obtain a license. For more information check the MATLAB API at The toolboxes installed as part of the campus license can be found with the command ver Contents MATLAB GUI Writing code Getting Help and Documentation Path Scope Workspace clean up Variable Initialisation Basic Operators Matrix Handling Cells Indexing Structures Printing to command window Conditionals State Checks For loops External Functions Plotting 3D Scatter Plot Load / Save k means clustering GMM Marked Tasks: MATLAB GUI The main MATLAB window shows a number of key areas. These can be arranged to your preference in the "Layout" selection of the "Environment" tab in the IDE. A: Current Folder The current working directory. B: Variables Viewer for exploring matrices and data structures in the workspace. C: Editor Built in IDE for script and function development. D: Workspace Current variables available in memory. E: Command Window Prompt interface for code prototyping. F: Command History Previously entered code for easy access. Writing code When writing MATLAB code there is the ability to quickly prototype code within the Command Window, or to write program scripts or functions in the the Editor. Scripts execute as if typed directly into the command window, and share the base workspace variables. Functions have their own individual workspace, and only have scope to this workspace. A script or function is called by entering its filename without the '.m' extension. Comments are preceeded by the percentage symbol '%', use these to document your code for future reference! All work for this module should be called from a script. If you wish to implement certain elements as functions this is fine, however they should then be called via the main script.
2 Getting Help and Documentation If information is required about a certain function then it is often possible to search the documentation or the help function by calling 'doc' and 'help' on the function of interest. help plus + Plus. X + Y adds matrices X and Y. X and Y must have the same dimensions unless one is a scalar (a 1-by-1 matrix). A scalar can be added to anything. C = PLUS(A,B) is called for the syntax 'A + B' when A or B is an object. Reference page in Doc Center doc plus Other functions named plus calendarduration/plus gf/plus laurmat/plus codistributed/plus gpuarray/plus laurpoly/plus cvdata/plus icsignal/plus sym/plus datetime/plus InputOutputModel/plus timeseries/plus duration/plus Path Scope MATLAB can only see files that are on its defined path. Any new directories that you wish to work with must be added to the current session's path by right clicking on the directory and selecting "Add to Path" and then choosing "Selected folders and subfolders". Workspace clean up When working in MATLAB it can be useful to tidy up the environment. clc % Clear command window. clear % Clear current workspace variables. clear X % Clear variable X from current workspace. close % Close current figure. close all % Close all open figures. Variable Initialisation The basis of MATLAB usage is in the handling of vectors and matrices. The common syntax is to enclose a matrix using square brackets. Initialise 1*1 double A with a value of 1 Initialise 1*3 vector B of the values 4, 5 and 6, incrementing in steps of +1. A comma separates columns. Initialise a vector C containing values from 0 to 100 in steps of 10 A = 1 B = [4,5,6] C = 0:10:100 A = 1 B = C = Initialise 3*3 matrix D. A semicolon separates rows Intialise 5*4*2 matrix of zeros E D = [1,2,3;4,5,6;7,8,9] E = zeros(5,4,2)
3 D = E(:,:,1) = E(:,:,2) = Initialise 3*3 matrix of magic numbers F, ones G, NaNs H and infs I F = magic(3) G = ones(3) H = nan(3) I = inf(3) F = G = H = NaN NaN NaN NaN NaN NaN NaN NaN NaN I = Inf Inf Inf Inf Inf Inf Inf Inf Inf Basic Operators Plus + and Minus [1,2,3] + 2 [1,2,3] - [3,2,1] %[1,2,3] + [1,2] % Will not work
4 Elementwise Multiplication.* and Division./ 1.* 2 % Equal to the scalar multiplication 1 * 2 [1,2].* 2 [1,2].* [3,2] %[1,2,3].* [1,2] % Will not work [15,8,3]./ [5,4,3] Matrix Multiplication * 1 * 2 [1,2] * 2 % Equal to the scalar multiplication [1,2].* 2 %[1,2] * [3,2] % Will not work [1,2] * [3;2] % Same as 1*3+2*2 [1;2] * [3,2] % Same as 1*3,1*2;2*3,2* Raise to power ^ and elementwise power.^ 5^2 [5,6].^ [2,3]
5 Matrix Handling Transpose (reflect along diagonal/swap row and column indices) with apostrophe/single quote J = magic(4) J' J = Reshape F from 3*3 matrix to a 8*2 vector. Note the columnwise operation! J reshape(j,8,2) J = Cells Cells allow us to hold data of varying types and sizes. Each cell element then stores its own contents which can be accessed directly. Initialise 3*3 cell matrix K = cell(3) K = [] [] [] [] [] [] [] [] [] Cells are accessed using brace notation. K{1,1} = [1,2,3,4]; K{1,2} = 'Cells are fun!'; % Single quotes surround a string K{3,3} = cell(1,10); K K = [1x4 double] 'Cells are fun!' [] [] [] [] [] [] {1x10 cell}
6 We can index contents within a cell in the normal fashion. K{1,1}(1,4) = 9001; % This accesses the fourth element within the first cell and changes it to 9001 K{1,1} Indexing If we want to access a given element in a vector/matrix/array we utilise indexing. Note that MATLAB index starts from 1! F F = Subscript indexing: Index into ith row and jth column F(i,j) F(1,3) % Row 1, column 3 6 Range index with colon operator: F(1,:) % Row 1, all columns F(1:2,2:end) % Rows 1 and 2, columns 2 to the last Linear indexing Index into ith element F(i). Note columnwise. F(7) % 7th columnwise element 6 Logical indexing Index using a logical array/matrix corresponding to the matrix we are indexing index = F < 5 % Logical indices of A lower than 15 F(index) = 0 % Set these elements to 0 index =
7 F = Structures Structure arrays in MATLAB hold data within fields that can vary in size and types. L(1).fieldname1 = 5; L(1).fieldname2 = 'Here'; L(1).fieldname3 = [1,2,3;4,5,6]; L(2).fieldname1 = 1337; L(2).fieldname2 = 'There'; L(2).fieldname3 = [3,4,1;5,7,2;3,4,5]; L L = 1x2 struct array with fields: fieldname1 fieldname2 fieldname3 Data stored with a given field is accessed via dot notation. L(1).fieldname2 Here Printing to command window Ommiting semicolon prints variable to the command window. Nice for tracing through a program, hideous when you have large matrices. Try ones(1000,1000) to see why. F F = Surpress this output with semicolon. F; % This won't be printed fprintf fprintf('csm77 is fun!'); CSM77 is fun! fprintf can handle string specifiers and variables from the workspace linenum = [1,2, ]; fprintf('line %d\nline %d\nline %.2f',lineNum); Line 1 Line 2 Line 3.14
8 Conditionals Blocks in MATLAB start with the keyword and end with the 'end' keyword. Indentation is not required but is encouraged in good practice. Read up on the NOT (~), AND (&), and OR () logical operators. Note AND and OR have short circuit logical operators in (&& and ). condition = 9; if condition >= 10 fprintf('here.\n'); elseif condition >= 0 fprintf('there.\n'); else fprintf('everywhere.\n'); end There. State Checks is*(x) detects the state of an entity X in the workspace. This is useful to determine the property of a variable before performing some function on it M = [nan,5,inf,10] M = NaN 5 Inf 10 isnan(m) isinf(m) isempty(m) For loops Loops in MATLAB create an index variable and iterate through a vector in sequential order n = 5; t = 0; for i = 1 : n t = t + 1; end t t = 5 While loops check a condition before exectuting the statement inside while t > 0 t = t - 1; end t t = 0
9 External Functions The below code shows MATLAB function notation. These are saved into their own.m file and located on the path for use in other functions and scripts. function [output] = addone(input) output = input + 1; end These can then be called by their function name. n = 1; n = addone(n) n = 2 Plotting figure; % Open new figure x1 = 0:pi/10:4*pi; % Create a vector of linearly spaced datapoints for x y1 = sin(x1); % plot(x1,y1); % Plot our first wave xlabel('x'); % Label our axes ylabel('y'); title('plot of Waves'); hold on; % Hold the current figure so that we can plot without clearing y2 = cos(x1); plot(x1,y2,':r') %plot our cos wave wih a dotted red line 3D Scatter Plot figure; z = 0:(4*pi)/250:4*pi; x = 2*cos(z); y = 2*sin(z); scatter3(x,y,z) % plot our data in the new figure xlabel('x') ylabel('y') zlabel('z')
10 Load / Save Saving a selection of workspace variables requires the filename and the variables to save into the.mat file. Ommitting the second argument saves all current workspace variables. save('csm77_savefile'); % Loading data from a.mat file is just as easy. Provide the filename to % load the whole file, or specific variables to save memory. clear; % Clear the workspace so that we can see it is reloaded. load('csm77_savefile'); k means clustering The following section implements k means algorithm on some built in dataset. Our basic pipeline is as follows: Load the data Visualise the feature space Select features for clustering Call the kmeans function on the data Check the clustering performance by plotting label assignments Make sure to use doc or help to check the usage of different functions. 1 Load data and visualise feature space clear; clc; close all; % workspace cleanup load('kmeansdata','x') % load the variable X from the built-in kmeansdata dataset. There are 560 observations and 4 recorded features. featurelabels = {'D1';'D2';'D3';'D4'}; % give some informative labels to the features truthlabels = []; % we don't have any ground truth color = []; % we don't need different colors markersymbol = []; % we don't need different symbols markersize = [];% we don't need different marker sizes drawlegend = 1; diagstyle = 'stairs'; % what to plot on the diagonal figure gplotmatrix(x,x,truthlabels,color,markersymbol,markersize,drawlegend,diagstyle,featurelabels,featurelabels)% visualise feat relations title('feature space scatter matrix for X') 2 Set up kmeans parameters and perform clustering %Perform k-means on X. We can cheat here because we know there are 4 %clusters, however run this multiple times to see that k-means only reaches %a local minima. Try altering the number of clusters (k) to see the %effect. feats = [1,2,3,4]; % select features to cluster data = X(:,feats); k = 4; % number of clusters maximumiter = 100; % maximum number of kmeans iterations to run starttype = 'sample'; % the centroid position seed. Try: 'cluster', 'plus' and 'uniform' nrep = 1; % number of times to perform kmeans, returns the clustering with lowest sum of distances 3 Perform k means clustering [idx,c] = kmeans(data,k,'start',starttype,'maxiter',maximumiter,'replicates',nrep); %perform kmeans
11 4 Plot k means clustering results figure; gscatter(data(:,1),data(:,2),idx) % scatter plot X against Y with group labels in idx hold on plot(c(:,1),c(:,2),'kx','markersize',15,'linewidth',3) % highlight centroids title 'K-Means Clustering' xlabel('d2') ylabel('d1') GMM The following section implements the fitting of a Gaussian Mixture model to the same data as above. We follow a similar pipeline as before: Load the data Visualise the feature space Select features for clustering Call the GMM fitting function on the data Check the clustering performance by plotting label assignments Plot the 99% confidence coverage 1 Load data and visualise feature space clear; clc; close all; % workspace cleanup load('kmeansdata','x') % load the variable X from the built-in kmeansdata dataset. There are 560 observations and 4 recorded features. featurelabels = {'D1';'D2';'D3';'D4'}; % give some informative labels to the features truthlabels = []; % we don't have any ground truth color = []; % we don't need different colors markersymbol = []; % we don't need different symbols markersize = [];% we don't need different marker sizes drawlegend = 1; diagstyle = 'stairs'; % what to plot on the diagonal figure gplotmatrix(x,x,truthlabels,color,markersymbol,markersize,drawlegend,diagstyle,featurelabels,featurelabels)% visualise feat relations title('feature space scatter matrix for X')
12 2 Select data for clustering feats = [1,2,3,4]; % select features to cluster data = X(:,feats); 3 Set up GMM parameters Try altering these parameters, and try further ones outlined in doc fitgmdist k = 4; % number of clusters starttype = 'randsample'; % the centroid position seed. Try: 'cluster', 'plus' and 'uniform' nrep = 1; % number of times to perform kmeans, returns the clustering with lowest sum of distances 4 Fit GMM to data and cluster original observations GMM = fitgmdist(data,k,'start',starttype,'replicates',nrep); % fits GMM predictedy = cluster(gmm,data); % cluster the observations in X using the model GMM 5 Plot clustering and the model confidence coverage plotcolors = parula(k); % make some colors threshold = sqrt(chi2inv(0.99,k)); % Determine confidence threshold figure hold on for ik = 1:k % for every cluster % create grid that covers the input space d = 300; x1 = linspace(min(data(:,1)),max(data(:,1)),d); x2 = linspace(min(data(:,2)),max(data(:,2)),d); x3 = GMM.mu(ik,3); x4 = GMM.mu(ik,4); [x1grid,x2grid,x3grid,x4grid] = ndgrid(x1,x2,x3,x4); X0 = [x1grid(:) x2grid(:) x3grid(:) x4grid(:)]; % Calculate Mahalanobis distance of points to the GMM mus mahaldist = mahal(gmm,x0); % Select points that fall under threshold idx = mahaldist(:,ik)<=threshold; %find coverage for 99% for Gaussian m % Plot the Gaussian coverage plot(x0(idx,1),x0(idx,2),'.','color',plotcolors(ik,:),'markersize',5); alpha(.5) end % Plot data points points gscatter(data(:,1),data(:,2),predictedy); % plot predicted clustering plot(gmm.mu(:,1),gmm.mu(:,2),'kx','linewidth',2,'markersize',10) % plot GMM mus title 'GMM Clustering' xlabel('d1') ylabel('d2')
13 Marked Tasks: Part 1: MATLAB The first task is to follow through this labsheet and the lecture slides on the MATLAB syntax. Write a script that performs the above code. Take your time to go through each point and understand the basics of the syntax. It is important that you are able to inspect MATLAB code that we give out in the coming lab sessions. Once you have finished, we will come and check your script, before signing you off. Part 2: K means and GMMs Perform clustering on the built in Fisher iris dataset. The choice of parameters are up to you. We will check your scripts in the lab and sign you off. Please provide both a kmeans AND GMM clustering, these can be in separate scripts for ease of reading. Follow the pipeline from above: Load the data Visualise the feature space Select features for clustering Call the kmeans function on the data Check the clustering performance by plotting label assignments Consider the following: 1. How many observations are there in the dataset? 2. How many features are there? 3. What is the true number of clusters? 4. What impact will altering a kmeans parameter have on performance? Hints: The Fisher iris dataset can be loaded by calling load fisheriris The Fisher iris dataset contains two variables: meas and species meas contains the data observations, species is a cell array of the data labels You can find further information regarding the dataset online. Even though we are using data driven clustering methods, we do have ground truth labels for each point. This can be useful in evaluating how our clustering has performed. The gscatter plotting function can take labels from species as an argument, i.e. gscatter(x(:,1),x(:,2),y) check doc gscatter. Published with MATLAB R2016a
Introduction to MATLAB
ELG 3125 - Lab 1 Introduction to MATLAB TA: Chao Wang (cwang103@site.uottawa.ca) 2008 Fall ELG 3125 Signal and System Analysis P. 1 Do You Speak MATLAB? MATLAB - The Language of Technical Computing ELG
More informationConstraint-based Metabolic Reconstructions & Analysis H. Scott Hinton. Matlab Tutorial. Lesson: Matlab Tutorial
1 Matlab Tutorial 2 Lecture Learning Objectives Each student should be able to: Describe the Matlab desktop Explain the basic use of Matlab variables Explain the basic use of Matlab scripts Explain the
More informationMATLAB BASICS. M Files. Objectives
Objectives MATLAB BASICS 1. What is MATLAB and why has it been selected to be the tool of choice for DIP? 2. What programming environment does MATLAB offer? 3. What are M-files? 4. What is the difference
More informationIntroduction to Matlab
Introduction to Matlab Andreas C. Kapourani (Credit: Steve Renals & Iain Murray) 9 January 08 Introduction MATLAB is a programming language that grew out of the need to process matrices. It is used extensively
More informationMATLAB Basics. Configure a MATLAB Package 6/7/2017. Stanley Liang, PhD York University. Get a MATLAB Student License on Matworks
MATLAB Basics Stanley Liang, PhD York University Configure a MATLAB Package Get a MATLAB Student License on Matworks Visit MathWorks at https://www.mathworks.com/ It is recommended signing up with a student
More informationMATLAB Programming for Numerical Computation Dr. Niket Kaisare Department Of Chemical Engineering Indian Institute of Technology, Madras
MATLAB Programming for Numerical Computation Dr. Niket Kaisare Department Of Chemical Engineering Indian Institute of Technology, Madras Module No. #01 Lecture No. #1.1 Introduction to MATLAB programming
More informationIntroduction to Matlab. By: Dr. Maher O. EL-Ghossain
Introduction to Matlab By: Dr. Maher O. EL-Ghossain Outline: q What is Matlab? Matlab Screen Variables, array, matrix, indexing Operators (Arithmetic, relational, logical ) Display Facilities Flow Control
More informationIntroduction to MATLAB LAB 1
Introduction to MATLAB LAB 1 1 Basics of MATLAB MATrix LABoratory A super-powerful graphing calculator Matrix based numeric computation Embedded Functions Also a programming language User defined functions
More informationMATLAB TUTORIAL WORKSHEET
MATLAB TUTORIAL WORKSHEET What is MATLAB? Software package used for computation High-level programming language with easy to use interactive environment Access MATLAB at Tufts here: https://it.tufts.edu/sw-matlabstudent
More informationIntroduction to MATLAB Programming
Introduction to MATLAB Programming Arun A. Balakrishnan Asst. Professor Dept. of AE&I, RSET Overview 1 Overview 2 Introduction 3 Getting Started 4 Basics of Programming Overview 1 Overview 2 Introduction
More informationMatlab Tutorial. The value assigned to a variable can be checked by simply typing in the variable name:
1 Matlab Tutorial 1- What is Matlab? Matlab is a powerful tool for almost any kind of mathematical application. It enables one to develop programs with a high degree of functionality. The user can write
More informationIntroduction to. The Help System. Variable and Memory Management. Matrices Generation. Interactive Calculations. Vectors and Matrices
Introduction to Interactive Calculations Matlab is interactive, no need to declare variables >> 2+3*4/2 >> V = 50 >> V + 2 >> V Ans = 52 >> a=5e-3; b=1; a+b Most elementary functions and constants are
More informationINTRODUCTION TO NUMERICAL ANALYSIS
INTRODUCTION TO NUMERICAL ANALYSIS Cho, Hyoung Kyu Department of Nuclear Engineering Seoul National University 0. MATLAB USAGE 1. Background MATLAB MATrix LABoratory Mathematical computations, modeling
More informationMATLAB COURSE FALL 2004 SESSION 1 GETTING STARTED. Christian Daude 1
MATLAB COURSE FALL 2004 SESSION 1 GETTING STARTED Christian Daude 1 Introduction MATLAB is a software package designed to handle a broad range of mathematical needs one may encounter when doing scientific
More informationDesktop Command window
Chapter 1 Matlab Overview EGR1302 Desktop Command window Current Directory window Tb Tabs to toggle between Current Directory & Workspace Windows Command History window 1 Desktop Default appearance Command
More informationMatlab Tutorial 1: Working with variables, arrays, and plotting
Matlab Tutorial 1: Working with variables, arrays, and plotting Setting up Matlab First of all, let's make sure we all have the same layout of the different windows in Matlab. Go to Home Layout Default.
More informationIntroduction to Scientific Computing with Matlab
UNIVERSITY OF WATERLOO Introduction to Scientific Computing with Matlab SAW Training Course R. William Lewis Computing Consultant Client Services Information Systems & Technology 2007 Table of Contents
More informationGetting started with MATLAB
Sapienza University of Rome Department of economics and law Advanced Monetary Theory and Policy EPOS 2013/14 Getting started with MATLAB Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Outline
More informationMATLAB Tutorial. 1. The MATLAB Windows. 2. The Command Windows. 3. Simple scalar or number operations
MATLAB Tutorial The following tutorial has been compiled from several resources including the online Help menu of MATLAB. It contains a list of commands that will be directly helpful for understanding
More informationAppendix A. Introduction to MATLAB. A.1 What Is MATLAB?
Appendix A Introduction to MATLAB A.1 What Is MATLAB? MATLAB is a technical computing environment developed by The Math- Works, Inc. for computation and data visualization. It is both an interactive system
More informationIntroduction to MATLAB
Chapter 1 Introduction to MATLAB 1.1 Software Philosophy Matrix-based numeric computation MATrix LABoratory built-in support for standard matrix and vector operations High-level programming language Programming
More informationDSP Laboratory (EELE 4110) Lab#1 Introduction to Matlab
Islamic University of Gaza Faculty of Engineering Electrical Engineering Department 2012 DSP Laboratory (EELE 4110) Lab#1 Introduction to Matlab Goals for this Lab Assignment: In this lab we would have
More informationMcTutorial: A MATLAB Tutorial
McGill University School of Computer Science Sable Research Group McTutorial: A MATLAB Tutorial Lei Lopez Last updated: August 2014 w w w. s a b l e. m c g i l l. c a Contents 1 MATLAB BASICS 3 1.1 MATLAB
More informationCourse Layout. Go to https://www.license.boun.edu.tr, follow instr. Accessible within campus (only for the first download)
Course Layout Lectures 1: Variables, Scripts and Operations 2: Visualization and Programming 3: Solving Equations, Fitting 4: Images, Animations, Advanced Methods 5: Optional: Symbolic Math, Simulink Course
More informationThe Mathematics of Big Data
The Mathematics of Big Data Linear Algebra and MATLAB Philippe B. Laval KSU Fall 2015 Philippe B. Laval (KSU) Linear Algebra and MATLAB Fall 2015 1 / 23 Introduction We introduce the features of MATLAB
More informationMatlab notes Matlab is a matrix-based, high-performance language for technical computing It integrates computation, visualisation and programming usin
Matlab notes Matlab is a matrix-based, high-performance language for technical computing It integrates computation, visualisation and programming using familiar mathematical notation The name Matlab stands
More informationIntroduction to MATLAB
Introduction to MATLAB Introduction: MATLAB is a powerful high level scripting language that is optimized for mathematical analysis, simulation, and visualization. You can interactively solve problems
More informationELEC4042 Signal Processing 2 MATLAB Review (prepared by A/Prof Ambikairajah)
Introduction ELEC4042 Signal Processing 2 MATLAB Review (prepared by A/Prof Ambikairajah) MATLAB is a powerful mathematical language that is used in most engineering companies today. Its strength lies
More informationOutline. CSE 1570 Interacting with MATLAB. Starting MATLAB. Outline (Cont d) MATLAB Windows. MATLAB Desktop Window. Instructor: Aijun An
CSE 170 Interacting with MATLAB Instructor: Aijun An Department of Computer Science and Engineering York University aan@cse.yorku.ca Outline Starting MATLAB MATLAB Windows Using the Command Window Some
More information1 Introduction to Matlab
1 Introduction to Matlab 1. What is Matlab? Matlab is a computer program designed to do mathematics. You might think of it as a super-calculator. That is, once Matlab has been started, you can enter computations,
More informationECON 502 INTRODUCTION TO MATLAB Nov 9, 2007 TA: Murat Koyuncu
ECON 502 INTRODUCTION TO MATLAB Nov 9, 2007 TA: Murat Koyuncu 0. What is MATLAB? 1 MATLAB stands for matrix laboratory and is one of the most popular software for numerical computation. MATLAB s basic
More informationOutline. CSE 1570 Interacting with MATLAB. Starting MATLAB. Outline. MATLAB Windows. MATLAB Desktop Window. Instructor: Aijun An.
CSE 170 Interacting with MATLAB Instructor: Aijun An Department of Computer Science and Engineering York University aan@cse.yorku.ca Outline Starting MATLAB MATLAB Windows Using the Command Window Some
More informationExperiment 1: Introduction to MATLAB I. Introduction. 1.1 Objectives and Expectations: 1.2 What is MATLAB?
Experiment 1: Introduction to MATLAB I Introduction MATLAB, which stands for Matrix Laboratory, is a very powerful program for performing numerical and symbolic calculations, and is widely used in science
More informationAn Introduction to MATLAB II
Lab of COMP 319 An Introduction to MATLAB II Lab tutor : Gene Yu Zhao Mailbox: csyuzhao@comp.polyu.edu.hk or genexinvivian@gmail.com Lab 2: 16th Sep, 2013 1 Outline of Lab 2 Review of Lab 1 Matrix in Matlab
More informationMATLAB for beginners. KiJung Yoon, 1. 1 Center for Learning and Memory, University of Texas at Austin, Austin, TX 78712, USA
MATLAB for beginners KiJung Yoon, 1 1 Center for Learning and Memory, University of Texas at Austin, Austin, TX 78712, USA 1 MATLAB Tutorial I What is a matrix? 1) A way of representation for data (# of
More informationMATLAB SUMMARY FOR MATH2070/2970
MATLAB SUMMARY FOR MATH2070/2970 DUNCAN SUTHERLAND 1. Introduction The following is inted as a guide containing all relevant Matlab commands and concepts for MATH2070 and 2970. All code fragments should
More informationIntroduction to MATLAB
CHEE MATLAB Tutorial Introduction to MATLAB Introduction In this tutorial, you will learn how to enter matrices and perform some matrix operations using MATLAB. MATLAB is an interactive program for numerical
More informationAn Introduction to Matlab5
An Introduction to Matlab5 Phil Spector Statistical Computing Facility University of California, Berkeley August 21, 2006 1 Background Matlab was originally developed as a simple interface to the LINPACK
More informationDigital Image Analysis and Processing CPE
Digital Image Analysis and Processing CPE 0907544 Matlab Tutorial Dr. Iyad Jafar Outline Matlab Environment Matlab as Calculator Common Mathematical Functions Defining Vectors and Arrays Addressing Vectors
More informationIntroduction to Matlab. By: Hossein Hamooni Fall 2014
Introduction to Matlab By: Hossein Hamooni Fall 2014 Why Matlab? Data analytics task Large data processing Multi-platform, Multi Format data importing Graphing Modeling Lots of built-in functions for rapid
More informationMATLAB Introduction. Contents. Introduction to Matlab. Published on Advanced Lab (
Published on Advanced Lab (http://experimentationlab.berkeley.edu) Home > References > MATLAB Introduction MATLAB Introduction Contents 1 Introduction to Matlab 1.1 About Matlab 1.2 Prepare Your Environment
More informationWhat is MATLAB? What is MATLAB? Programming Environment MATLAB PROGRAMMING. Stands for MATrix LABoratory. A programming environment
What is MATLAB? MATLAB PROGRAMMING Stands for MATrix LABoratory A software built around vectors and matrices A great tool for numerical computation of mathematical problems, such as Calculus Has powerful
More informationMATH (CRN 13695) Lab 1: Basics for Linear Algebra and Matlab
MATH 495.3 (CRN 13695) Lab 1: Basics for Linear Algebra and Matlab Below is a screen similar to what you should see when you open Matlab. The command window is the large box to the right containing the
More informationGetting Started. Chapter 1. How to Get Matlab. 1.1 Before We Begin Matlab to Accompany Lay s Linear Algebra Text
Chapter 1 Getting Started How to Get Matlab Matlab physically resides on each of the computers in the Olin Hall labs. See your instructor if you need an account on these machines. If you are going to go
More informationDr Richard Greenaway
SCHOOL OF PHYSICS, ASTRONOMY & MATHEMATICS 4PAM1008 MATLAB 3 Creating, Organising & Processing Data Dr Richard Greenaway 3 Creating, Organising & Processing Data In this Workshop the matrix type is introduced
More informationECE Lesson Plan - Class 1 Fall, 2001
ECE 201 - Lesson Plan - Class 1 Fall, 2001 Software Development Philosophy Matrix-based numeric computation - MATrix LABoratory High-level programming language - Programming data type specification not
More informationOutline. CSE 1570 Interacting with MATLAB. Outline. Starting MATLAB. MATLAB Windows. MATLAB Desktop Window. Instructor: Aijun An.
CSE 10 Interacting with MATLAB Instructor: Aijun An Department of Computer Science and Engineering York University aan@cse.yorku.ca Outline Starting MATLAB MATLAB Windows Using the Command Window Some
More informationLaboratory 1 Octave Tutorial
Signals, Spectra and Signal Processing Laboratory 1 Octave Tutorial 1.1 Introduction The purpose of this lab 1 is to become familiar with the GNU Octave 2 software environment. 1.2 Octave Review All laboratory
More informationEGR 102 Introduction to Engineering Modeling. Lab 05A Managing Data
EGR 102 Introduction to Engineering Modeling Lab 05A Managing Data 1 Overview Review Structured vectors in MATLAB Creating Vectors/arrays:» Linspace» Colon operator» Concatenation Initializing variables
More informationSTAT/MATH 395 A - PROBABILITY II UW Winter Quarter Matlab Tutorial
STAT/MATH 395 A - PROBABILITY II UW Winter Quarter 2016 Néhémy Lim Matlab Tutorial 1 Introduction Matlab (standing for matrix laboratory) is a high-level programming language and interactive environment
More informationIntroduc)on to Matlab
Introduc)on to Matlab Marcus Kaiser (based on lecture notes form Vince Adams and Syed Bilal Ul Haq ) MATLAB MATrix LABoratory (started as interac)ve interface to Fortran rou)nes) Powerful, extensible,
More informationMATLAB Lesson I. Chiara Lelli. October 2, Politecnico di Milano
MATLAB Lesson I Chiara Lelli Politecnico di Milano October 2, 2012 MATLAB MATLAB (MATrix LABoratory) is an interactive software system for: scientific computing statistical analysis vector and matrix computations
More informationWhat is MATLAB? It is a high-level programming language. for numerical computations for symbolic computations for scientific visualizations
What is MATLAB? It stands for MATrix LABoratory It is developed by The Mathworks, Inc (http://www.mathworks.com) It is an interactive, integrated, environment for numerical computations for symbolic computations
More informationLab of COMP 406. MATLAB: Quick Start. Lab tutor : Gene Yu Zhao Mailbox: or Lab 1: 11th Sep, 2013
Lab of COMP 406 MATLAB: Quick Start Lab tutor : Gene Yu Zhao Mailbox: csyuzhao@comp.polyu.edu.hk or genexinvivian@gmail.com Lab 1: 11th Sep, 2013 1 Where is Matlab? Find the Matlab under the folder 1.
More informationIntroduction to MATLAB
Computational Photonics, Seminar 0 on Introduction into MATLAB, 3.04.08 Page Introduction to MATLAB Operations on scalar variables >> 6 6 Pay attention to the output in the command window >> b = b = >>
More informationFinding, Starting and Using Matlab
Variables and Arrays Finding, Starting and Using Matlab CSC March 6 &, 9 Array: A collection of data values organized into rows and columns, and known by a single name. arr(,) Row Row Row Row 4 Col Col
More informationA General Introduction to Matlab
Master Degree Course in ELECTRONICS ENGINEERING http://www.dii.unimore.it/~lbiagiotti/systemscontroltheory.html A General Introduction to Matlab e-mail: luigi.biagiotti@unimore.it http://www.dii.unimore.it/~lbiagiotti
More informationAMATH 352: MATLAB Tutorial written by Peter Blossey Department of Applied Mathematics University of Washington Seattle, WA
AMATH 352: MATLAB Tutorial written by Peter Blossey Department of Applied Mathematics University of Washington Seattle, WA MATLAB (short for MATrix LABoratory) is a very useful piece of software for numerical
More informationIntroduction to Matlab
Introduction to Matlab 1 Outline: What is Matlab? Matlab Screen Variables, array, matrix, indexing Operators (Arithmetic, relational, logical ) Display Facilities Flow Control Using of M-File Writing User
More informationMATLAB and Numerical Analysis
School of Mechanical Engineering Pusan National University dongwoonkim@pusan.ac.kr Teaching Assistant 김동운 dongwoonkim@pusan.ac.kr 윤종희 jongheeyun@pusan.ac.kr Lab office: 통합기계관 120호 ( 510-3921) 방사선영상연구실홈페이지
More informationIntroduction to Matlab to Accompany Linear Algebra. Douglas Hundley Department of Mathematics and Statistics Whitman College
Introduction to Matlab to Accompany Linear Algebra Douglas Hundley Department of Mathematics and Statistics Whitman College August 27, 2018 2 Contents 1 Getting Started 5 1.1 Before We Begin........................................
More informationAn Introduction to Numerical Methods
An Introduction to Numerical Methods Using MATLAB Khyruddin Akbar Ansari, Ph.D., P.E. Bonni Dichone, Ph.D. SDC P U B L I C AT I O N S Better Textbooks. Lower Prices. www.sdcpublications.com Powered by
More informationIntroduction to Matlab
Introduction to Matlab Outline: What is Matlab? Matlab Screen Variables, array, matrix, indexing Operators (Arithmetic, relational, logical ) Display Facilities Flow Control Using of M-File Writing User
More informationIntroduction to MATLAB
Introduction to MATLAB 1 Introduction to MATLAB A Tutorial for the Course Computational Intelligence http://www.igi.tugraz.at/lehre/ci Stefan Häusler Institute for Theoretical Computer Science Inffeldgasse
More informationMATLAB Basics EE107: COMMUNICATION SYSTEMS HUSSAIN ELKOTBY
MATLAB Basics EE107: COMMUNICATION SYSTEMS HUSSAIN ELKOTBY What is MATLAB? MATLAB (MATrix LABoratory) developed by The Mathworks, Inc. (http://www.mathworks.com) Key Features: High-level language for numerical
More informationLearning from Data Introduction to Matlab
Learning from Data Introduction to Matlab Amos Storkey, David Barber and Chris Williams a.storkey@ed.ac.uk Course page : http://www.anc.ed.ac.uk/ amos/lfd/ This is a modified version of a text written
More informationA Guide to Using Some Basic MATLAB Functions
A Guide to Using Some Basic MATLAB Functions UNC Charlotte Robert W. Cox This document provides a brief overview of some of the essential MATLAB functionality. More thorough descriptions are available
More informationScilab Programming. The open source platform for numerical computation. Satish Annigeri Ph.D.
Scilab Programming The open source platform for numerical computation Satish Annigeri Ph.D. Professor, Civil Engineering Department B.V.B. College of Engineering & Technology Hubli 580 031 satish@bvb.edu
More informationIntroduction to MATLAB for Numerical Analysis and Mathematical Modeling. Selis Önel, PhD
Introduction to MATLAB for Numerical Analysis and Mathematical Modeling Selis Önel, PhD Advantages over other programs Contains large number of functions that access numerical libraries (LINPACK, EISPACK)
More information6.094 Introduction to MATLAB January (IAP) 2009
MIT OpenCourseWare http://ocw.mit.edu 6.094 Introduction to MATLAB January (IAP) 2009 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms. 6.094 Introduction
More informationHow to Use MATLAB. What is MATLAB. Getting Started. Online Help. General Purpose Commands
How to Use MATLAB What is MATLAB MATLAB is an interactive package for numerical analysis, matrix computation, control system design and linear system analysis and design. On the server bass, MATLAB version
More informationPhysics 326G Winter Class 2. In this class you will learn how to define and work with arrays or vectors.
Physics 326G Winter 2008 Class 2 In this class you will learn how to define and work with arrays or vectors. Matlab is designed to work with arrays. An array is a list of numbers (or other things) arranged
More informationUnix Computer To open MATLAB on a Unix computer, click on K-Menu >> Caedm Local Apps >> MATLAB.
MATLAB Introduction This guide is intended to help you start, set up and understand the formatting of MATLAB before beginning to code. For a detailed guide to programming in MATLAB, read the MATLAB Tutorial
More informationLab 4 CSE 7, Spring 2018 This lab is an introduction to using logical and comparison operators in Matlab.
LEARNING OBJECTIVES: Lab 4 CSE 7, Spring 2018 This lab is an introduction to using logical and comparison operators in Matlab 1 Use comparison operators (< > = == ~=) between two scalar values to create
More informationMatlab 1: Get Started
Matlab 1: Get Started 1 Starting/Existing Matlab 2/2 Run matlab in command line: In Terminal/console i.change to you work directory ii.type: matlab -nodesktop iii.to close it, type exit 3 Keep track of
More informationObjectives. 1 Running, and Interface Layout. 2 Toolboxes, Documentation and Tutorials. 3 Basic Calculations. PS 12a Laboratory 1 Spring 2014
PS 12a Laboratory 1 Spring 2014 Objectives This session is a tutorial designed to a very quick overview of some of the numerical skills that you ll need to get started. Throughout the tutorial, the instructors
More informationIntroduction to Matlab
Introduction to Matlab Kristian Sandberg Department of Applied Mathematics University of Colorado Goal The goal with this worksheet is to give a brief introduction to the mathematical software Matlab.
More informationIntroduction and MATLAB Basics
Introduction and MATLAB Basics Lecture Computer Room MATLAB MATLAB: Matrix Laboratory, designed for matrix manipulation Pro: Con: Syntax similar to C/C++/Java Automated memory management Dynamic data types
More informationMATLAB Tutorial. Mohammad Motamed 1. August 28, generates a 3 3 matrix.
MATLAB Tutorial 1 1 Department of Mathematics and Statistics, The University of New Mexico, Albuquerque, NM 87131 August 28, 2016 Contents: 1. Scalars, Vectors, Matrices... 1 2. Built-in variables, functions,
More information1 Overview of the standard Matlab syntax
1 Overview of the standard Matlab syntax Matlab is based on computations with matrices. All variables are matrices. Matrices are indexed from 1 (and NOT from 0 as in C!). Avoid using variable names i and
More informationFinding MATLAB on CAEDM Computers
Lab #1: Introduction to MATLAB Due Tuesday 5/7 at noon This guide is intended to help you start, set up and understand the formatting of MATLAB before beginning to code. For a detailed guide to programming
More informationMechanical Engineering Department Second Year (2015)
Lecture 7: Graphs Basic Plotting MATLAB has extensive facilities for displaying vectors and matrices as graphs, as well as annotating and printing these graphs. This section describes a few of the most
More informationGetting To Know Matlab
Getting To Know Matlab The following worksheets will introduce Matlab to the new user. Please, be sure you really know each step of the lab you performed, even if you are asking a friend who has a better
More informationIntroduction to MATLAB
Introduction to MATLAB Chen Huang Computer Science and Engineering SUNY at Buffalo What is MATLAB? MATLAB (stands for matrix laboratory ) It is a language and an environment for technical computing Designed
More informationComputational Photonics, Seminar 01 on Introduction into MATLAB, Page 1
Computational Photonics, Seminar 0 on Introduction into MATLAB,.04.06 Page Introduction to MATLAB Operations on scalar variables >> a=6 6 Pay attention to the response from the workspace >> b= b = >> a+b
More informationPART 1 PROGRAMMING WITH MATHLAB
PART 1 PROGRAMMING WITH MATHLAB Presenter: Dr. Zalilah Sharer 2018 School of Chemical and Energy Engineering Universiti Teknologi Malaysia 23 September 2018 Programming with MATHLAB MATLAB Environment
More informationINTRODUCTION TO MATLAB PROGRAMMING Lec 1.1: MATLAB Basics
INTRODUCTION TO MATLAB PROGRAMMING Lec 1.1: MATLAB Basics Dr. Niket Kaisare Department of Chemical Engineering IIT Madras NPTEL Course: MATLAB Programming for Numerical Computations Week-1 About this Module
More informationMachine Learning Exercise 0
Machine Learning Exercise 0 Introduction to MATLAB 19-04-2016 Aljosa Osep RWTH Aachen http://www.vision.rwth-aachen.de osep@vision.rwth-aachen.de 1 Experiences with Matlab? Who has worked with Matlab before?
More informationAn Introduction to MATLAB
An Introduction to MATLAB Day 1 Simon Mitchell Simon.Mitchell@ucla.edu High level language Programing language and development environment Built-in development tools Numerical manipulation Plotting of
More informationTo start using Matlab, you only need be concerned with the command window for now.
Getting Started Current folder window Atop the current folder window, you can see the address field which tells you where you are currently located. In programming, think of it as your current directory,
More informationInlichtingenblad, matlab- en simulink handleiding en practicumopgaven IWS
Inlichtingenblad, matlab- en simulink handleiding en practicumopgaven IWS 1 6 3 Matlab 3.1 Fundamentals Matlab. The name Matlab stands for matrix laboratory. Main principle. Matlab works with rectangular
More informationTUTORIAL MATLAB OPTIMIZATION TOOLBOX
TUTORIAL MATLAB OPTIMIZATION TOOLBOX INTRODUCTION MATLAB is a technical computing environment for high performance numeric computation and visualization. MATLAB integrates numerical analysis, matrix computation,
More informationFreeMat Tutorial. 3x + 4y 2z = 5 2x 5y + z = 8 x x + 3y = -1 xx
1 of 9 FreeMat Tutorial FreeMat is a general purpose matrix calculator. It allows you to enter matrices and then perform operations on them in the same way you would write the operations on paper. This
More informationCS 2750 Machine Learning. Matlab Tutorial
CS 2750 Machine Learning Matlab Tutorial Content based on Matlab tutorial file by Milos Hauskrecht: http://people.cs.pitt.edu/~milos/courses/cs2750/tutorial/ Slides prepared by Jeongmin Lee 1 Outline Part
More informationMATLAB Tutorial EE351M DSP. Created: Thursday Jan 25, 2007 Rayyan Jaber. Modified by: Kitaek Bae. Outline
MATLAB Tutorial EE351M DSP Created: Thursday Jan 25, 2007 Rayyan Jaber Modified by: Kitaek Bae Outline Part I: Introduction and Overview Part II: Matrix manipulations and common functions Part III: Plots
More informationMatlab is a tool to make our life easier. Keep that in mind. The best way to learn Matlab is through examples, at the computer.
Learn by doing! The purpose of this tutorial is to provide an introduction to Matlab, a powerful software package that performs numeric computations. The examples should be run as the tutorial is followed.
More informationCreates a 1 X 1 matrix (scalar) with a value of 1 in the column 1, row 1 position and prints the matrix aaa in the command window.
EE 350L: Signals and Transforms Lab Spring 2007 Lab #1 - Introduction to MATLAB Lab Handout Matlab Software: Matlab will be the analytical tool used in the signals lab. The laboratory has network licenses
More informationStarting Matlab. MATLAB Laboratory 09/09/10 Lecture. Command Window. Drives/Directories. Go to.
Starting Matlab Go to MATLAB Laboratory 09/09/10 Lecture Lisa A. Oberbroeckling Loyola University Maryland loberbroeckling@loyola.edu http://ctx.loyola.edu and login with your Loyola name and password...
More informationIntroduction to MatLab. Introduction to MatLab K. Craig 1
Introduction to MatLab Introduction to MatLab K. Craig 1 MatLab Introduction MatLab and the MatLab Environment Numerical Calculations Basic Plotting and Graphics Matrix Computations and Solving Equations
More informationInteractive Computing with Matlab. Gerald W. Recktenwald Department of Mechanical Engineering Portland State University
Interactive Computing with Matlab Gerald W. Recktenwald Department of Mechanical Engineering Portland State University gerry@me.pdx.edu Starting Matlab Double click on the Matlab icon, or on unix systems
More information