Introudction to Computation and Cognition 2015 Dr. Oren Shriki Shay Ben-Sasson, Ofer Groweiss. MATLAB tutorial

Size: px
Start display at page:

Download "Introudction to Computation and Cognition 2015 Dr. Oren Shriki Shay Ben-Sasson, Ofer Groweiss. MATLAB tutorial"

Transcription

1 Introudction to Computation and Cognition 2015 Dr. Oren Shriki Shay Ben-Sasson, Ofer Groweiss MATLAB tutorial 1

2 MATLAB is a general-purpose mathematical software that is user friendly and very useful for data analysis, simulations, presentation of results, and more. The software runs on both UNIX and WINDOWS, on a PC or on a MAC MATLAB is an interpreter, which means that it performs every command line immediately after it is entered. A script file for MATLAB is called an m-file and it must have the extension 'm' (i.e. something like xxx.m). To run an m-file, you just enter the name of the file without the extension at the MATLAB prompt or press F5 to save and run (when the file is open in the editor). To evaluate a part of a MATLAB file, you mark the corresponding lines and press F9. Getting started If you are a first-time user, you should run MATLAB now and follow along. The main tool of the MATLAB is the matrix (The name MATLAB stands for 'matrix laboratory'). REMEMBER THAT: (almost) EVERYTHING IS A MATRIX IN MATLAB A matrix of one element is called a scalar and we can create one by entering: >> s = 3 We have just created a variable. Its name is "s", its value is three. Notice that writing s=3 results in the Command Window also writing s=3. In order to suppress the Command Window's output, we use the ';' symbol at the end of the line: >> s = 3; What happens if we don't assign a variable? Writing: >> Creates a default variable called 'ans'. The resulting Command Window output will show ans = 8, and the variable ans will appear in the Workspace window. 2

3 Comments Writing '%' symbol before anything creates a comments. Comments are ignored by the interpreter. A multi-line comment can be created starting %{ and ending with }% (they both have to be on a dedicated line). Try this: % A single line comment %{ A multi line Comment %} Vectors A matrix of one row or one column is called a vector. We can create a row vector by entering: >> v = [8,3,5] Note: comma (,) differentiates between number in a row. Another way to differentiate is by using space. >> v = [8 3 5] Notice the use of brackets ([ ]). In order to declare a vector or matrix, we start and end the input with brackets. To create a column vector we will use the ';' symbol to separate between the elements >> u = [4.2; 5; 7] Matrices We can create a 3-by-3 matrix simply by entering >> A = [3 4 0; 1 4 6; 9 7 2] 3

4 Note the fact that you don't have to define a variable type ( int, double for those of you that have experience in programming languages) - you just enter it. We can now calculate quantities like the transpose of A (Aij Aji) >> A' (the hyphen ' is a shortcut for the transpose() function) or the transpose of v which will be a column vector: >> v' For example we can create another 3 by 3 matrix by entering >> B=[v; u'; 1 0 4] Important to note: Matlab is strict about dimensional matching. >> B=[v'; u; 1 0 4] would produce a common error: Error using horzcat Dimensions of matrices being concatenated are not consistent. If we have several matrices, we can add them >> A+B or multiply them >> A*B but we have to take care that the dimensions are appropriate. The multiplication operation we just used obeys the rules of ordinary matrix multiplication. There is another kind of multiplication, which is multiplying each element in a matrix by the corresponding element in another matrix which has to be the same size (this is called array multiplication or element-by-element multiplication). To do this you enter 4

5 >> A.*B This dot rule is general, so if you enter >> A.^2 it will raise all the elements of A to the power of 2 (which is of course different from A^2, which is A*A). Functions MATLAB has some commands/functions for the construction of special matrices. Some functions require parameter (input) and return a value (output). Functions are like mini scripts/programs that perform a designated action. The function 'ones' creates a vector or matrix filled with ones (1). The amount of ones is defined by the parameters, which are received as input inside parenthesis. >> ones(3,4) will create a matrix of 1's with 3 rows and 4 columns. Q1: there is no 'twos' or 'threes' function, why is this? You can figure out what >> zeros(5,7) does. To create an identity matrix of order 5 you type >> eye(5) 5

6 Size() and Length() What if we wanted to know the size of a matrix that is stored in the variable A. Let s try: >> size(a) We get a 3-by-3, 3 rows and 3 columns (on 2d matrix - the first dimension is always rows and then the 2 nd dimension is columns). >> size(a ) We got the same result, a 3-by-3. >> C = [10 15] Can you guess what are the dimensions of the matrix C (yes I know it s a vector, But everything in MATLAB is a )? Run size(c) to verify your answer. We get a vector result of [1 2], we have 1 row and 2 columns so C is a column vector, right? No, it s a bit confusing, it s a row vector, we have a single row with element values. >> size(c ) C is just transpose(c), hence, the transpose of C which equals [10;15], this is a column vector and the result of size(c ) is [2 1]. The function length just outputs the value of the dimension with the maximum value, in our case it s 2: >> length(c) Defining a range of numbers If you type >> x=1:10 This will give a vector with all the integer numbers from 1 to 10, and >> y=0:0.1:8 will give a vector of all the numbers between 0 and 8 with a 0.1 step. Note the use of the ':' symbol. It represents range, starting number (left), step size (middle) and ending number (right). By default, Matlab treats 1:10 as 1:1:10, meaning the step size is 1. 6

7 The number of elements in a vector is determined by the step, in order to have a fixed number of elements we use the linspace function: >> z = linspace(1,100,5) This will create a vector containing 5 elements, the first is 1, the last is 100, and the step size is determined by the number of elements. Using the help If you would like to learn about the syntax and the different uses of a command just type 'help' and the name of the command. For example try this: >> help rand A quicker way to use the Matlab internal help is: >> doc rand This will just output a summary of the function help in the Command Window 7

8 If you want to search for commands related to some topic, say complex numbers, you enter >> lookfor complex (Most of the times you need help, just use google.com, it a brand new company that has a great search engine, you should try it out). Indices: Scalars, vectors and matrices are in fact just matrices (remember the mantra: EVERTHING IN MATLAB IS A MATRIX). A scalar is matrix of order 1X1, and a vector is matrix of order 1XN or NX1. Indices are "pointers" (don t be confused with pointers in other programming languages) to locations inside a matrix. In Matlab they are called logicals (we will learn what that means later). In order to access an element inside a matrix, we must tell Matlab which row/s and/or column/s we would like to access. The order is ALWAYS rows, then columns. To access the first element in vector u, we will call: >> u(1,1) %access the value in row 1 column 1 in the vector u After we created a matrix we might want to extract some elements from it. To extract the i'th element of a vector you type >> v(1,i) %assuming v is a row vector or >> v(i) Typing the command A(i, j) will extract the element of A that sits in the i'th row in the j'th column. For example: >> A(2,3) 8

9 will extract the element in the 2 nd row in the 3 rd column. Typing the command: >> A(:,1:2) will extract the first 2 columns of A. When do we use just 'i' and when do we use 'i' and 'j'? Vectors can receive just 'i' because there's only one dimension. When accessing an element in a matrix it's common to use both 'i' and 'j' (although it's not mandatory). Suppose we want to know the sum of the 3 rd row. We will use the colon (:) and the function sum like this: >> sum(a(3,:)) for the sum of the third column we would type: >> sum(a(:,3)) Conditionals Now, type the following command: >> A>3 What you got is a new matrix, with ones and zeros. Every place with one means that the corresponding entry in A fulfills the condition (bigger than 3). Zeros means that the opposite is true, that is, the number is smaller or equal to 3. We now go further by typing: >> (A>3).* A can you explain the result? 9

10 hint: notice we used the element by element multiplier (.*) Operator precedence Try this and explain the result: >> A.*A > 5*A What runs first? The element-wise multiplication of the > operator or the * matrix multiplication: See the list here, it s ordered from the highest precedence to the lowest precedence. In our example, the.* expression is first evaluated, than the * expression and only than the > because of its relative lower precedence. More general functions and commands Until this stage, every result was displayed on the screen. If you don't want to see the result, just add a ';' at the end of the command. You can use the ';' also to separate different commands on the same line like this >> x=3; y=[1 x ones(1,5); 5*rand(1,7); 1:7]; Try it and then type >> y to see what we got. While working with MATLAB, you can always list the variables in the workspace by entering 'who' or 'whos' ('whos' shows also the size of the variables) To log everything you type in the workspace (and the results), use the 'diary' command. To start, enter something like: >> diary my_log.txt and to stop saving, enter: 10

11 >> diary off Type 'help diary' to see exactly what it does. diff function: The function diff(v) receives an input a vector v of n element and returns a vector of (n-1) elements. For each two adjacent elements in v, diff calculates the difference between them. For example, if u = diff(v), then u(1) = v(2)-v(1), u(2) = v(3)-v(2), etc. find function: find is a very useful function that can be very tricky. The function finds the indices of all non zero elements in a matrix. Say we have vector v = [2,0,7], then find(v) returns [1,3]. Now say we want to find the locations of elements equal to a certain number (for example, the number 7), this can be done with find(v==7). To understand how this works, let's break down the steps: v==7 is a logical statement, it creates a logical matrix the same size as v, where every element in index i is the answer to the clause 'if v(i) == 7'. The output of v==7 in our example will be [0,0,1], because only the third element is in fact 7. This is why the output of find(v==7) will be 3. In vectors, this function usually returns the desired output, but in matrices it can be tricky. More practice Sum, transpose, and diag You're probably already aware that the special properties of a magic square have to do with the various ways of summing its elements. If you take the sum along any row or column, or along either of the two main diagonals, you will always get the same number. Let's verify that using MATLAB. The first statement to try is sum(a) MATLAB replies with ans =

12 When you don't specify an output variable, MATLAB uses the variable ans, short for answer, to store the results of a calculation. You have computed a row vector containing the sums of the columns of A. Sure enough, each of the columns has the same sum, the magic sum, 34. How about the row sums? MATLAB has a preference for working with the columns of a matrix, so the easiest way to get the row sums is to transpose the matrix, compute the column sums of the transpose, and then transpose the result. The transpose operation is denoted by an apostrophe or single quote, '. It flips a matrix about its main diagonal and it turns a row vector into a column vector. So A' Produces:ans = And sum(a')' produces a column vector containing the row sums ans = The sum of the elements on the main diagonal is easily obtained with the help of the diag function, which picks off that diagonal. diag(a) produces ans =

13 7 1 and sum(diag(a)) produces ans = 34 The other diagonal, the so-called antidiagonal, is not so important mathematically, so MATLAB does not have a ready-made function for it. But a function originally intended for use in graphics, fliplr, flips a matrix from left to right. sum(diag(fliplr(a))) ans = 34 You have verified that the matrix in Dürer's engraving is indeed a magic square and, in the process, have sampled a few MATLAB matrix operations. The following sections continue to use this matrix to illustrate additional MATLAB capabilities. Subscripts The element in row i and column j of A is denoted by A(i,j). For example, A(4,2) is the number in the fourth row and second column. For our magic square, A(4,2) is 15. So it is possible to compute the sum of the elements in the fourth column of A by typing A(1,4) + A(2,4) + A(3,4) + A(4,4) This produces ans = 34 but is not the most elegant way of summing a single column. It is also possible to refer to the elements of a matrix with a single subscript, A(k). This is the usual way of referencing row and column vectors. But it can also apply to a fully twodimensional matrix, in which case the array is regarded as one long column vector formed 13

14 from the columns of the original matrix. So, for our magic square, A(8) is another way of referring to the value 15 stored in A(4,2). If you try to use the value of an element outside of the matrix, it is an error: t = A(4,5) Index exceeds matrix dimensions. On the other hand, if you store a value in an element outside of the matrix, the size increases to accommodate the newcomer: X = A; X(4,5) = 17 X = The Colon Operator The colon, :, is one of MATLAB's most important operators. It occurs in several different forms. The expression 1:10 is a row vector containing the integers from 1 to To obtain nonunit spacing, specify an increment. For example 100:-7:50 is and 0:pi/4:pi is 14

15 Subscript expressions involving colons refer to portions of a matrix. A(1:k,j) is the first k elements of the jth column of A. So sum(a(1:4,4)) computes the sum of the fourth column. But there is a better way. The colon by itself refers to all the elements in a row or column of a matrix and the keyword end refers to the last row or column. So sum(a(:,end)) computes the sum of the elements in the last column of A. ans = 34 Why is the magic sum for a 4-by-4 square equal to 34? If the integers from 1 to 16 are sorted into four groups with equal sums, that sum must be sum(1:16)/4 which, of course, is ans = 34 Arrays When they are taken away from the world of linear algebra, matrices become twodimensional numeric arrays. Arithmetic operations on arrays are done element-byelement. This means that addition and subtraction are the same for arrays and matrices, but that multiplicative operations are different. MATLAB uses a dot, or decimal point, as part of the notation for multiplicative array operations. The list of operators includes: + Addition - Subtraction 15

16 .* Element-by-element multiplication./ Element-by-element division.\ Element-by-element left division.^ Element-by-element power.' Unconjugated array transpose If the Dürer magic square is multiplied by itself with array multiplication A.*A the result is an array containing the squares of the integers from 1 to 16, in an unusual order. ans = Array operations are useful for building tables. Suppose n is the column vector: n = (0:9)'; Then pows = [n n.^2 2.^n] builds a table of squares and powers of two. pows =

17 The elementary math functions operate on arrays element by element. So format short g x = (1:0.1:2)'; logs = [x log10(x)] builds a table of logarithms. logs = 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 of exercise per week For five observations, the resulting array might look like: D =

18 The first row contains the heart rate, weight, and exercise hours for patient 1, the second row contains the data for patient 2, and so on. Now you can apply many of MATLAB's data analysis functions to this data set. For example, to obtain the mean and standard deviation of each column: mu = mean(d), sigma = std(d) mu = sigma = For a list of the data analysis functions available in MATLAB, type help datafun If you have access to the Statistics Toolbox, type help stats Scalar Expansion Matrices and scalars can be combined in several different ways. For example, a scalar is subtracted from a matrix by subtracting it from each element. The average value of the elements in our magic square is 8.5, so B = A forms a matrix whose column sums are zero. B = sum(b) ans =

19 With scalar expansion, MATLAB assigns a specified scalar to all indices in a range. For example: B(1:2,2:3) = 0 zeros out a portion of B B = Logical Subscripting The logical vectors created from logical and relational operations can be used to reference subarrays. Suppose X is an ordinary matrix and L is a matrix of the same size that is the result of some logical operation. Then X(L) specifies the elements of X where the elements of L are nonzero. This kind of subscripting can be done in one step by specifying the logical operation as the subscripting expression. Suppose you have the following set of data. x = NaN The NaN is a marker for a missing observation, such as a failure to respond to an item on a questionnaire. To remove the missing data with logical indexing, use finite(x), which is true for all finite numerical values and false for NaN and Inf. x = x(finite(x)) x = Now there is one observation, 5.1, which seems to be very different from the others. It is an outlier. The following statement removes outliers, in this case those elements more than three standard deviations from the mean. x = x(abs(x-mean(x)) <= 3*std(x)) x =

20 For another example, highlight the location of the prime numbers in Dürer's magic square by using logical indexing and scalar expansion to set the nonprimes to 0. A(~isprime(A)) = 0 A = The find Function The find function determines the indices of array elements that meet a given logical condition. In its simplest form, find returns a column vector of indices. Transpose that vector to obtain a row vector of indices. For example k = find(isprime(a))' picks out the locations, using one-dimensional indexing, of the primes in the magic square. k = Display those primes, as a row vector in the order determined by k, with A(k) ans = When you use k as a left-hand-side index in an assignment statement, the matrix structure is preserved. A(k) = NaN A = 16 NaN NaN NaN NaN 10 NaN 8 20

21 9 6 NaN Graphics and Visualization MATLAB is indeed a great tool for visualization of data of all sorts. The first command you should learn how to use is the 'plot'. If you want to plot vector y versus vector x just type >> plot(x,y( MATLAB will produce a figure window and will plot the graph. For example, type the following: >> x = 0:0.01:pi*4 >> plot(x, sin(x)) To learn more about the 'plot' command, try the help on it. To present several plots on the same figure, use the 'subplot' command. To create another figure window, use the 'figure' command. Now, we shall learn about a useful command: hist. With hist you get nice histograms very quickly. Try this: >> x = rand(1000,1) ; this will create a vector with 1000 elements and store it in x. >> max(x) this is the greatest element >> max(x) min(x) this is the difference between the greatest and lowest >> hist(x) what did you get? try this: >> y = rand(1000,1) >> hist (x+y) 21

22 this is the same idea >> plot(x, y,. ) >> title( A big mess ) >> xlabel( vector x ) >> ylabel( vector y ) remember that every Matlab function (even those you will write) has input arguments and output arguments. The input arguments are what you put between the brackets, for example in plot(x,y) x and y are the inputs. The output is what you get back from the function. For example in m = max(x) the result of the max function is placed in m. The variables you use to get the output are the glue between the various commands. In order to find about the input and output of functions, simply type the magic word help. The following commands will help you control the way your graphs look: axis, xlabel, ylabel, title, hold, grid, get, set, gca, gcf Here is a list of some specialized 2-D functions: bar - creates a bar graph errorbar - creates a plot with error bars The best way to learn about MATLAB visualization capabilities is to see the demo and then learn about the commands that are most useful for you. Note that the demos are written in MATLAB so you can "type" the files and just copy the commands you need. To type a file inside MATLAB's workspace you enter for example >> type lorenz.m This program plots the orbit around the Lorenz chaotic attractor. If you want to run it just type >> lorenz 22

23 Data Analysis Here we list few functions, which are very useful for data analysis: max - maximum value min - minimum value mean - mean value median - median value std - standard deviation sort sorting sum -sum of the elements prod - product of elements cumsum - cumulative sum of elements cumprod - cumulative product of elements diff - approximate derivatives corrcoef - correlation coefficients cov - covariance matrix For vector arguments, it does not matter whether the vectors are oriented in a row or column direction. For array arguments, the functions operate in a column-oriented fashion on the data in the array. This means, for example, that if you apply 'max' to an array, the result is a row vector containing the maximum values over each column. If A is a matrix and you want the maximal element just type >> max(max(a)) Typing help on each of these functions will give you the full description of them. Note that, although it is very easy to write most of these functions yourself, it is nice to already have them and it makes the scripts more compact. 23

24 Loops and Clauses Sometimes we would like to perform an operation multiple times, or perform only certain operations if certain condition are met. IF clause A clause is a statement that has Boolean value, either true or false. Clauses rely on the understanding of logical if A, then B. A clause is identified by the word if. Here is an example. >> A = [1,2] We want to add a third number, if and only if, the second element in A is 2. >> if A(2)==2 A(3) = 3; end When writing if in the command window, pressing the enter key will not run the program just yet. The clause if has a scope the range in which the if applies. We identify where the scope ends by the command end. Every if has an end. What we did in the example is ask a question is the second element of A equal to 2? if indeed the answer is yes, then we add a three, and if not, we do nothing. ELSE Everything that doesn t fall under the if condition, falls under else. In our previous example, let s change the value of the second element in A if it is not 2: >> if A(2)==2 A(3) = 3; else A(2) = 2; end What happens if we don t specify an else condition? Matlab creates one but does nothing, this is invisible to the user. Another way to differentiate between condition is to use elseif. This clause means that the if condition isn t met but we have another condition: 24

25 >> if A(2)==2 A(3) = 3; elseif A(1)==1 A(3) = 3; else A(2) = 2; end We expanded our conditions and now we want to add a 3 even if the second element isn t 2 but the first is 1. Logical operators: In the last example we made a redundant step. Instead of asking if and then elseif, we can combine the two condition using OR. Remember, in logic A or B means that at least one of the statements needs to be true. Logical operators symbols: & (and), (or, Shift+\), ~ (not) So in order to write the previous example we use : >> if A(2)==2 A(1)==1 A(3) = 3; else A(2) = 2; end Why did we use two symbols? It s more efficient. A double or symbol doesn t check the second condition if the first is true. A double and symbol doesn t check the second condition if the first is false. More examples: >> if A(2)==2 && A(1)==1 A(3) = 3; end Here we will only perform the A(3)=3 operation only if both clauses are met. >> if ~(A(2)==2 ) A(3) = 3; end This is the exact opposite of the first example using the not operator. 25

26 While loop One thing that we would like to avoid while programming is hard-coding. This means writing down exactly what we want the code to do. So what we do if we want to perform 100 operation? we can hard code at least 100 lines of code, but this is redundant. We can use a loop to perform similar operation in a sequential manner (one after the other). A while loop is an if clause that is repeated as long as the if is true. Every repeating step is called an iteration. We can use this in order to have timed-loops, meaning a loop that runs for a given time. The functions tic and toc are like the buttons on a stopwatch. tic starts the timer and and toc measures how much passed this the last tic ( toc can be called multiple times, like the lap button on a stopwatch). An example for a timed loop: >> tic; >> while toc< end This example runs for 3 seconds and prints 757 in every iteration. What happens after 3 seconds? toc<3 is false, and therefore the loop stops. A very common while-loop is a counter loop, that sequentially iterates for a known number of steps. If we wanted to print every element in a vector v, we can do the following: >> v = 1:10; >> counter = 1; >> while counter <= length(v) v(counter) counter = counter + 1; end Once the counter is raised to 11, the loop breaks. This loop was so common that it we actually shortened for easier use, and not it s called: For loops: A for loop that operates the same the last example, is written as follows: >> for i = 1:length(v) v(i) end 26

27 Where is a the i=i+1? it is done in the background, invisible to the user. A for loop iterates over a vector, in the last example, that vector is 1:length(v). We have to create a for loop variable, in the last example that variable is i (short for index) we should never change i inside the loop trust the loop, it will increase i in every iteration. Uses: When should we for and when should we use while? A for loop is used if we know exactly how many iteration are needed. A while loop is used if we don t know the number of iterations. As a rule, while loops can do everything a for loop does, them why use for loops? First, they re short and accessible, but the main reason is that for loops will not perform infinite iterations. An infinite loop is a loop that never stops. A while loop that s not correctly configured will iterate forever. Here s an example: >> counter = 1; >> while counter <= length(v) v(counter) end What s wrong? We forgot to write counter = counter + 1;, meaning counter never increases and therefore is always <=length(v). To stop an infinite loop (or any script) press ctrl+c or ctrl+break in the command window. 27

MATLAB COURSE FALL 2004 SESSION 1 GETTING STARTED. Christian Daude 1

MATLAB 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 information

A Brief MATLAB Tutorial

A Brief MATLAB Tutorial POLYTECHNIC UNIVERSITY Department of Computer and Information Science A Brief MATLAB Tutorial K. Ming Leung Abstract: We present a brief MATLAB tutorial covering only the bare-minimum that a beginner needs

More information

Introduction to Matlab

Introduction to Matlab Introduction to Matlab By:Mohammad Sadeghi *Dr. Sajid Gul Khawaja Slides has been used partially to prepare this presentation Outline: What is Matlab? Matlab Screen Basic functions Variables, matrix, indexing

More information

MATLAB TUTORIAL WORKSHEET

MATLAB 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 information

Introduction to MATLAB

Introduction 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 information

Introduction to MATLAB. Computational Probability and Statistics CIS 2033 Section 003

Introduction to MATLAB. Computational Probability and Statistics CIS 2033 Section 003 Introduction to MATLAB Computational Probability and Statistics CIS 2033 Section 003 About MATLAB MATLAB (MATrix LABoratory) is a high level language made for: Numerical Computation (Technical computing)

More information

ELEC4042 Signal Processing 2 MATLAB Review (prepared by A/Prof Ambikairajah)

ELEC4042 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 information

MAT 343 Laboratory 1 Matrix and Vector Computations in MATLAB

MAT 343 Laboratory 1 Matrix and Vector Computations in MATLAB MAT 343 Laboratory 1 Matrix and Vector Computations in MATLAB In this laboratory session we will learn how to 1. Create matrices and vectors. 2. Manipulate matrices and create matrices of special types

More information

Getting started with MATLAB

Getting 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 information

AMATH 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 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 information

Constraint-based Metabolic Reconstructions & Analysis H. Scott Hinton. Matlab Tutorial. Lesson: Matlab Tutorial

Constraint-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 information

Introduction to. The Help System. Variable and Memory Management. Matrices Generation. Interactive Calculations. Vectors and Matrices

Introduction 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 information

Introduction to Matlab. By: Dr. Maher O. EL-Ghossain

Introduction 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 information

Mathworks (company that releases Matlab ) documentation website is:

Mathworks (company that releases Matlab ) documentation website is: 1 Getting Started The Mathematics Behind Biological Invasions Introduction to Matlab in UNIX Christina Cobbold and Tomas de Camino Beck as modified for UNIX by Fred Adler Logging in: This is what you do

More information

MAT 343 Laboratory 1 Matrix and Vector Computations in MATLAB

MAT 343 Laboratory 1 Matrix and Vector Computations in MATLAB MAT 343 Laboratory 1 Matrix and Vector Computations in MATLAB MATLAB is a computer software commonly used in both education and industry to solve a wide range of problems. This Laboratory provides a brief

More information

MATLAB: The Basics. Dmitry Adamskiy 9 November 2011

MATLAB: The Basics. Dmitry Adamskiy 9 November 2011 MATLAB: The Basics Dmitry Adamskiy adamskiy@cs.rhul.ac.uk 9 November 2011 1 Starting Up MATLAB Windows users: Start up MATLAB by double clicking on the MATLAB icon. Unix/Linux users: Start up by typing

More information

Introduction to MATLAB. Simon O Keefe Non-Standard Computation Group

Introduction to MATLAB. Simon O Keefe Non-Standard Computation Group Introduction to MATLAB Simon O Keefe Non-Standard Computation Group sok@cs.york.ac.uk Content n An introduction to MATLAB n The MATLAB interfaces n Variables, vectors and matrices n Using operators n Using

More information

Some elements for Matlab programming

Some elements for Matlab programming Some elements for Matlab programming Nathalie Thomas 2018 2019 Matlab, which stands for the abbreviation of MATrix LABoratory, is one of the most popular language for scientic computation. The classical

More information

2.0 MATLAB Fundamentals

2.0 MATLAB Fundamentals 2.0 MATLAB Fundamentals 2.1 INTRODUCTION MATLAB is a computer program for computing scientific and engineering problems that can be expressed in mathematical form. The name MATLAB stands for MATrix LABoratory,

More information

Introduction to MATLAB

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 information

1 Introduction to Matlab

1 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 information

Stokes Modelling Workshop

Stokes Modelling Workshop Stokes Modelling Workshop 14/06/2016 Introduction to Matlab www.maths.nuigalway.ie/modellingworkshop16/files 14/06/2016 Stokes Modelling Workshop Introduction to Matlab 1 / 16 Matlab As part of this crash

More information

Introduction to Octave/Matlab. Deployment of Telecommunication Infrastructures

Introduction to Octave/Matlab. Deployment of Telecommunication Infrastructures Introduction to Octave/Matlab Deployment of Telecommunication Infrastructures 1 What is Octave? Software for numerical computations and graphics Particularly designed for matrix computations Solving equations,

More information

Lecture 2: Variables, Vectors and Matrices in MATLAB

Lecture 2: Variables, Vectors and Matrices in MATLAB Lecture 2: Variables, Vectors and Matrices in MATLAB Dr. Mohammed Hawa Electrical Engineering Department University of Jordan EE201: Computer Applications. See Textbook Chapter 1 and Chapter 2. Variables

More information

MATLAB 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 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 information

Introduction to MATLAB

Introduction 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 information

Introduction to MatLab. Introduction to MatLab K. Craig 1

Introduction 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 information

Dr Richard Greenaway

Dr 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 information

Introduction to Matlab

Introduction to Matlab Introduction to Matlab What is Matlab The software program called Matlab (short for MATrix LABoratory) is arguably the world standard for engineering- mainly because of its ability to do very quick prototyping.

More information

Matlab Tutorial and Exercises for COMP61021

Matlab Tutorial and Exercises for COMP61021 Matlab Tutorial and Exercises for COMP61021 1 Introduction This is a brief Matlab tutorial for students who have not used Matlab in their programming. Matlab programming is essential in COMP61021 as a

More information

Introduction to MATLAB LAB 1

Introduction 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 information

Interactive 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 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

How to learn MATLAB? Some predefined variables

How to learn MATLAB? Some predefined variables ECE-S352 Lab 1 MATLAB Tutorial How to learn MATLAB? 1. MATLAB comes with good tutorial and detailed documents. a) Select MATLAB help from the MATLAB Help menu to open the help window. Follow MATLAB s Getting

More information

Getting Started with MATLAB

Getting Started with MATLAB Getting Started with MATLAB Math 315, Fall 2003 Matlab is an interactive system for numerical computations. It is widely used in universities and industry, and has many advantages over languages such as

More information

Introduction to MATLAB programming: Fundamentals

Introduction to MATLAB programming: Fundamentals Introduction to MATLAB programming: Fundamentals Shan He School for Computational Science University of Birmingham Module 06-23836: Computational Modelling with MATLAB Outline Outline of Topics Why MATLAB?

More information

ECON 502 INTRODUCTION TO MATLAB Nov 9, 2007 TA: Murat Koyuncu

ECON 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 information

MATLAB GUIDE UMD PHYS401 SPRING 2011

MATLAB GUIDE UMD PHYS401 SPRING 2011 MATLAB GUIDE UMD PHYS401 SPRING 2011 Note that it is sometimes useful to add comments to your commands. You can do this with % : >> data=[3 5 9 6] %here is my comment data = 3 5 9 6 At any time you can

More information

Getting started with MATLAB

Getting started with MATLAB Getting started with MATLAB You can work through this tutorial in the computer classes over the first 2 weeks, or in your own time. The Farber and Goldfarb computer classrooms have working Matlab, but

More information

Octave Tutorial Machine Learning WS 12/13 Umer Khan Information Systems and Machine Learning Lab (ISMLL) University of Hildesheim, Germany

Octave Tutorial Machine Learning WS 12/13 Umer Khan Information Systems and Machine Learning Lab (ISMLL) University of Hildesheim, Germany Octave Tutorial Machine Learning WS 12/13 Umer Khan Information Systems and Machine Learning Lab (ISMLL) University of Hildesheim, Germany 1 Basic Commands Try Elementary arithmetic operations: 5+6, 3-2,

More information

Introduction to MATLAB

Introduction to MATLAB to MATLAB Spring 2019 to MATLAB Spring 2019 1 / 39 The Basics What is MATLAB? MATLAB Short for Matrix Laboratory matrix data structures are at the heart of programming in MATLAB We will consider arrays

More information

EE 301 Signals & Systems I MATLAB Tutorial with Questions

EE 301 Signals & Systems I MATLAB Tutorial with Questions EE 301 Signals & Systems I MATLAB Tutorial with Questions Under the content of the course EE-301, this semester, some MATLAB questions will be assigned in addition to the usual theoretical questions. This

More information

Introduction. Matlab for Psychologists. Overview. Coding v. button clicking. Hello, nice to meet you. Variables

Introduction. Matlab for Psychologists. Overview. Coding v. button clicking. Hello, nice to meet you. Variables Introduction Matlab for Psychologists Matlab is a language Simple rules for grammar Learn by using them There are many different ways to do each task Don t start from scratch - build on what other people

More information

OUTLINES. Variable names in MATLAB. Matrices, Vectors and Scalar. Entering a vector Colon operator ( : ) Mathematical operations on vectors.

OUTLINES. Variable names in MATLAB. Matrices, Vectors and Scalar. Entering a vector Colon operator ( : ) Mathematical operations on vectors. 1 LECTURE 3 OUTLINES Variable names in MATLAB Examples Matrices, Vectors and Scalar Scalar Vectors Entering a vector Colon operator ( : ) Mathematical operations on vectors examples 2 VARIABLE NAMES IN

More information

Vectors and Matrices. Chapter 2. Linguaggio Programmazione Matlab-Simulink (2017/2018)

Vectors and Matrices. Chapter 2. Linguaggio Programmazione Matlab-Simulink (2017/2018) Vectors and Matrices Chapter 2 Linguaggio Programmazione Matlab-Simulink (2017/2018) Matrices A matrix is used to store a set of values of the same type; every value is stored in an element MATLAB stands

More information

Introduction to MATLAB

Introduction to MATLAB Introduction to MATLAB Introduction MATLAB is an interactive package for numerical analysis, matrix computation, control system design, and linear system analysis and design available on most CAEN platforms

More information

MATLAB. The Language of Technical Computing. Getting Started with MATLAB Version 7

MATLAB. The Language of Technical Computing. Getting Started with MATLAB Version 7 MATLAB The Language of Technical Computing Getting Started with MATLAB Version 7 How to Contact The MathWorks: www.mathworks.com comp.soft-sys.matlab support@mathworks.com suggest@mathworks.com bugs@mathworks.com

More information

Matlab Tutorial for COMP24111 (includes exercise 1)

Matlab Tutorial for COMP24111 (includes exercise 1) Matlab Tutorial for COMP24111 (includes exercise 1) 1 Exercises to be completed by end of lab There are a total of 11 exercises through this tutorial. By the end of the lab, you should have completed the

More information

Chapter 1 Introduction to MATLAB

Chapter 1 Introduction to MATLAB Chapter 1 Introduction to MATLAB 1.1 What is MATLAB? MATLAB = MATrix LABoratory, the language of technical computing, modeling and simulation, data analysis and processing, visualization and graphics,

More information

MATLAB Basics EE107: COMMUNICATION SYSTEMS HUSSAIN ELKOTBY

MATLAB 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 information

This is a basic tutorial for the MATLAB program which is a high-performance language for technical computing for platforms:

This is a basic tutorial for the MATLAB program which is a high-performance language for technical computing for platforms: Appendix A Basic MATLAB Tutorial Extracted from: http://www1.gantep.edu.tr/ bingul/ep375 http://www.mathworks.com/products/matlab A.1 Introduction This is a basic tutorial for the MATLAB program which

More information

Grace days can not be used for this assignment

Grace days can not be used for this assignment CS513 Spring 19 Prof. Ron Matlab Assignment #0 Prepared by Narfi Stefansson Due January 30, 2019 Grace days can not be used for this assignment The Matlab assignments are not intended to be complete tutorials,

More information

ECE Lesson Plan - Class 1 Fall, 2001

ECE 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 information

MATLAB Vocabulary. Gerald Recktenwald. Version 0.965, 25 February 2017

MATLAB Vocabulary. Gerald Recktenwald. Version 0.965, 25 February 2017 MATLAB Vocabulary Gerald Recktenwald Version 0.965, 25 February 2017 MATLAB is a software application for scientific computing developed by the Mathworks. MATLAB runs on Windows, Macintosh and Unix operating

More information

Introduction to Matlab. Summer School CEA-EDF-INRIA 2011 of Numerical Analysis

Introduction to Matlab. Summer School CEA-EDF-INRIA 2011 of Numerical Analysis Introduction to Matlab 1 Outline What is Matlab? Matlab desktop & interface Scalar variables Vectors and matrices Exercise 1 Booleans Control structures File organization User defined functions Exercise

More information

Introduction to Matlab. By: Hossein Hamooni Fall 2014

Introduction 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 information

! The MATLAB language

! The MATLAB language E2.5 Signals & Systems Introduction to MATLAB! MATLAB is a high-performance language for technical computing. It integrates computation, visualization, and programming in an easy-to -use environment. Typical

More information

AN INTRODUCTION TO MATLAB

AN INTRODUCTION TO MATLAB AN INTRODUCTION TO MATLAB 1 Introduction MATLAB is a powerful mathematical tool used for a number of engineering applications such as communication engineering, digital signal processing, control engineering,

More information

MATLAB Basics. Configure a MATLAB Package 6/7/2017. Stanley Liang, PhD York University. Get a MATLAB Student License on Matworks

MATLAB 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 information

INTRODUCTION TO MATLAB

INTRODUCTION TO MATLAB 1 of 18 BEFORE YOU BEGIN PREREQUISITE LABS None EXPECTED KNOWLEDGE Algebra and fundamentals of linear algebra. EQUIPMENT None MATERIALS None OBJECTIVES INTRODUCTION TO MATLAB After completing this lab

More information

MATLAB Tutorial. Digital Signal Processing. Course Details. Topics. MATLAB Environment. Introduction. Digital Signal Processing (DSP)

MATLAB Tutorial. Digital Signal Processing. Course Details. Topics. MATLAB Environment. Introduction. Digital Signal Processing (DSP) Digital Signal Processing Prof. Nizamettin AYDIN naydin@yildiz.edu.tr naydin@ieee.org http://www.yildiz.edu.tr/~naydin Course Details Course Code : 0113620 Course Name: Digital Signal Processing (Sayısal

More information

To start using Matlab, you only need be concerned with the command window for now.

To 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 information

Lab 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: 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 information

Introduction to MATLAB

Introduction to MATLAB Introduction to MATLAB --------------------------------------------------------------------------------- Getting MATLAB to Run Programming The Command Prompt Simple Expressions Variables Referencing Matrix

More information

MATLAB Project: Getting Started with MATLAB

MATLAB Project: Getting Started with MATLAB Name Purpose: To learn to create matrices and use various MATLAB commands for reference later MATLAB functions used: [ ] : ; + - * ^, size, help, format, eye, zeros, ones, diag, rand, round, cos, sin,

More information

MATLAB Tutorial. Mohammad Motamed 1. August 28, generates a 3 3 matrix.

MATLAB 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 information

Lecturer: Keyvan Dehmamy

Lecturer: Keyvan Dehmamy MATLAB Tutorial Lecturer: Keyvan Dehmamy 1 Topics Introduction Running MATLAB and MATLAB Environment Getting help Variables Vectors, Matrices, and linear Algebra Mathematical Functions and Applications

More information

MATLAB Tutorial. 1. The MATLAB Windows. 2. The Command Windows. 3. Simple scalar or number operations

MATLAB 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 information

A Guide to Using Some Basic MATLAB Functions

A 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 information

MATLAB 7 Getting Started Guide

MATLAB 7 Getting Started Guide MATLAB 7 Getting Started Guide How to Contact The MathWorks www.mathworks.com Web comp.soft-sys.matlab Newsgroup www.mathworks.com/contact_ts.html Technical Support suggest@mathworks.com bugs@mathworks.com

More information

Laboratory 1 Octave Tutorial

Laboratory 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 information

Matlab (Matrix laboratory) is an interactive software system for numerical computations and graphics.

Matlab (Matrix laboratory) is an interactive software system for numerical computations and graphics. Matlab (Matrix laboratory) is an interactive software system for numerical computations and graphics. Starting MATLAB - On a PC, double click the MATLAB icon - On a LINUX/UNIX machine, enter the command:

More information

PowerPoints organized by Dr. Michael R. Gustafson II, Duke University

PowerPoints organized by Dr. Michael R. Gustafson II, Duke University Part 1 Chapter 2 MATLAB Fundamentals PowerPoints organized by Dr. Michael R. Gustafson II, Duke University All images copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

More information

Desktop Command window

Desktop 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 information

MATH (CRN 13695) Lab 1: Basics for Linear Algebra and Matlab

MATH (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 information

Matlab Introduction. Scalar Variables and Arithmetic Operators

Matlab Introduction. Scalar Variables and Arithmetic Operators Matlab Introduction Matlab is both a powerful computational environment and a programming language that easily handles matrix and complex arithmetic. It is a large software package that has many advanced

More information

MATLAB SUMMARY FOR MATH2070/2970

MATLAB 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 information

Introduction to Matlab

Introduction to Matlab What is Matlab? Introduction to Matlab Matlab is software written by a company called The Mathworks (mathworks.com), and was first created in 1984 to be a nice front end to the numerical routines created

More information

McTutorial: A MATLAB Tutorial

McTutorial: 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 information

MATLAB = MATrix LABoratory. Interactive system. Basic data element is an array that does not require dimensioning.

MATLAB = MATrix LABoratory. Interactive system. Basic data element is an array that does not require dimensioning. Introduction MATLAB = MATrix LABoratory Interactive system. Basic data element is an array that does not require dimensioning. Efficient computation of matrix and vector formulations (in terms of writing

More information

Introduction to MATLAB for Engineers, Third Edition

Introduction to MATLAB for Engineers, Third Edition PowerPoint to accompany Introduction to MATLAB for Engineers, Third Edition William J. Palm III Chapter 2 Numeric, Cell, and Structure Arrays Copyright 2010. The McGraw-Hill Companies, Inc. This work is

More information

Eric W. Hansen. The basic data type is a matrix This is the basic paradigm for computation with MATLAB, and the key to its power. Here s an example:

Eric W. Hansen. The basic data type is a matrix This is the basic paradigm for computation with MATLAB, and the key to its power. Here s an example: Using MATLAB for Stochastic Simulation. Eric W. Hansen. Matlab Basics Introduction MATLAB (MATrix LABoratory) is a software package designed for efficient, reliable numerical computing. Using MATLAB greatly

More information

MATLAB 7 Getting Started Guide

MATLAB 7 Getting Started Guide MATLAB 7 Getting Started Guide How to Contact MathWorks www.mathworks.com Web comp.soft-sys.matlab Newsgroup www.mathworks.com/contact_ts.html Technical Support suggest@mathworks.com bugs@mathworks.com

More information

Matlab Lecture 1 - Introduction to MATLAB. Five Parts of Matlab. Entering Matrices (2) - Method 1:Direct entry. Entering Matrices (1) - Magic Square

Matlab Lecture 1 - Introduction to MATLAB. Five Parts of Matlab. Entering Matrices (2) - Method 1:Direct entry. Entering Matrices (1) - Magic Square Matlab Lecture 1 - Introduction to MATLAB Five Parts of Matlab MATLAB is a high-performance language for technical computing. It integrates computation, visualization, and programming in an easy-touse

More information

Finding, Starting and Using Matlab

Finding, 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 information

CITS2401 Computer Analysis & Visualisation

CITS2401 Computer Analysis & Visualisation FACULTY OF ENGINEERING, COMPUTING AND MATHEMATICS CITS2401 Computer Analysis & Visualisation SCHOOL OF COMPUTER SCIENCE AND SOFTWARE ENGINEERING Topic 3 Introduction to Matlab Material from MATLAB for

More information

MATLAB Project: Getting Started with MATLAB

MATLAB Project: Getting Started with MATLAB Name Purpose: To learn to create matrices and use various MATLAB commands for reference later MATLAB built-in functions used: [ ] : ; + - * ^, size, help, format, eye, zeros, ones, diag, rand, round, cos,

More information

Getting To Know Matlab

Getting 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 information

Teaching Manual Math 2131

Teaching Manual Math 2131 Math 2131 Linear Algebra Labs with MATLAB Math 2131 Linear algebra with Matlab Teaching Manual Math 2131 Contents Week 1 3 1 MATLAB Course Introduction 5 1.1 The MATLAB user interface...........................

More information

MATLAB: Quick Start Econ 837

MATLAB: Quick Start Econ 837 MATLAB: Quick Start Econ 837 Introduction MATLAB is a commercial Matrix Laboratory package which operates as an interactive programming environment. It is a programming language and a computing environment

More information

LECTURE 1. What Is Matlab? Matlab Windows. Help

LECTURE 1. What Is Matlab? Matlab Windows. Help LECTURE 1 What Is Matlab? Matlab ("MATrix LABoratory") is a software package (and accompanying programming language) that simplifies many operations in numerical methods, matrix manipulation/linear algebra,

More information

Appendix A. Introduction to MATLAB. A.1 What Is MATLAB?

Appendix 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 information

University of Alberta

University of Alberta A Brief Introduction to MATLAB University of Alberta M.G. Lipsett 2008 MATLAB is an interactive program for numerical computation and data visualization, used extensively by engineers for analysis of systems.

More information

Introduc)on to Matlab

Introduc)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 information

Introduction to MATLAB

Introduction 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 information

What is Matlab? A software environment for interactive numerical computations

What is Matlab? A software environment for interactive numerical computations What is Matlab? A software environment for interactive numerical computations Examples: Matrix computations and linear algebra Solving nonlinear equations Numerical solution of differential equations Mathematical

More information

MATH-680: Mathematics of genome analysis Introduction to MATLAB

MATH-680: Mathematics of genome analysis Introduction to MATLAB MATH-680: Mathematics of genome analysis Introduction to MATLAB Jean-Luc Bouchot, Simon Foucart jean-luc.bouchot@drexel.edu January 14, 2013 1 Introduction As for the case of R, MATLAB is another example

More information

Introduction to Matlab

Introduction to Matlab Introduction to Matlab November 22, 2013 Contents 1 Introduction to Matlab 1 1.1 What is Matlab.................................. 1 1.2 Matlab versus Maple............................... 2 1.3 Getting

More information

Outline. User-based knn Algorithm Basics of Matlab Control Structures Scripts and Functions Help

Outline. User-based knn Algorithm Basics of Matlab Control Structures Scripts and Functions Help Outline User-based knn Algorithm Basics of Matlab Control Structures Scripts and Functions Help User-based knn Algorithm Three main steps Weight all users with respect to similarity with the active user.

More information

Introduction to MATLAB Programming

Introduction 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 information

Matlab Tutorial 1: Working with variables, arrays, and plotting

Matlab 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 information