MatLab Tutorial. Draft. Anthony S. Maida. October 8, 2001; revised 9/20/04; 3/23/06; 12/11/06

Size: px
Start display at page:

Download "MatLab Tutorial. Draft. Anthony S. Maida. October 8, 2001; revised 9/20/04; 3/23/06; 12/11/06"

Transcription

1 MatLab Tutorial Draft Anthony S. Maida October 8, 2001; revised 9/20/04; 3/23/06; 12/11/06 Contents 1 Introduction Is MatLab appropriate for your problem? Interpreted language Command window display Loading scripts from files Vectorizing code Matrices Statement terminators and output suppression Some matrix operators Flexible matrix access Loading data via a script Reading data the old-fashioned way Vector operations Examining the workspace Applying functions to matrix elements Vectorizing a feedforward network for one epoch Defining functions Plotting and visualization Simple plotting A useful example Application to neural networks D Plots Surface plots Other plotting commands Appendix 12 1

2 A Appendix: Matrix notation 12 A.1 Matrix multiplication A.2 Definition of transpose Introduction MATLAB stands for matrix laboratory and the name is a trademark of The MathWorks Incorporated. The purpose of this document is to give you enough background so that you effectively use the MATLAB built-in help system to solve your programming problems. 1.1 Is MatLab appropriate for your problem? MATLAB is effective in small applications where the appropriate data representations are vectors and matrices. Vectors and matrices are the appropriate data structure for nearly all non-trivial problems in scientific computing. MATLAB is especially useful for interactively plotting functions and visualizing scientific data. MATLAB is commercial software Interpreted language MATLAB is an interpreted language, hence, its programs are called scripts. To achieve efficiency, MATLAB allows the user to vectorize code by using matrices and their associated operators. The interpretation overhead for a vectorized instruction is then small compared to the amount of computation that the instruction does Command window display The user has a choice of using MATLAB interactively via a command window display (command-line shell; read-eval-print loop) or by loading prewritten scripts from files. The language is designed (e.g., variables need not be declared) so that commands evaluated in the read-eval-print loop will also work when loaded from a file. This facilitates rapid prototyping and debugging because you can test your command before putting it into a file. A simple command-line interaction session is shown below. >> ans = 4 The command-line prompt is >>. The system reads the expression 2 + 2, evaluates it, stores it in a default variable ans, and prints the value of this variable. The variable ans always has the result of the most recent computation that has not already been assigned a value. For instance, if we continue the session as shown below, the value of ans doesn t change. 1 If you cannot afford MatLab, then GNU OCTAVE ( is an alternative for interactive matrix computations and GNUPLOT ( is an alternative for plotting and visualizing data. 2

3 >> x = x = 5 >> ans ans = 4 At this point the workspace has two variables x and ans. The development environment has workspace editor which allows you to examine the variables in the workspace and how much space they consume. You can clear the workspace to its original state by typing the command clear. If you dislike clutter, you can use the command clc to clear the contents of the command window display Loading scripts from files You can use the MATLAB built-in editor to write scripts, save them to files, and then have them loaded and evaluated as if you typed the commands directly into the command line. Also, while in the command line shell, you can type the file name containing a MATLAB script to achieve the same effect. Text files containing MATLAB code are called m-files and have the file extension.m. As you develop a script, you will follow a cycle of editing and loading. When you reload your script, the workspace from the previous cycle will still be in effect unless you clear it. You probably want to clear it to avoid subtle reinitialization errors. The best way to do this is to put the clear command as the first line of the script, so that the script runs in a virgin workspace. 2 Vectorizing code Interpreted MATLAB scripts achieve efficiency in speed of execution by using large instructions to reduce decoding overhead and by using space to decrease time. For a given problem size, MATLAB scipts use a lot of memory. Thus MATLAB trades memory to increase speed. 2.1 Matrices The primary data structure in MATLAB is a matrix. The appendix in this tutorial has more information about matrices. You can create and initialize a matrix by typing the matrix values in an assignment statement. The example below creates a 3 2 matrix of doubleprecision floating-point values and then sets the variable w to reference the matrix. 2 Notice that the variable w was not previously declared. The rows of the matrix are terminated with semicolons. All the commands below create the same matrix. >> w = [1 2 3; 4 5 6] >> w = [1 2 3; 4 5 6;] >> w = [1, 2, 3; 4, 5, 6] >> w = [1, 2, 3; 4, 5, 6;] 2 Numbers in MATLAB are always double-precision floating-point. 3

4 MATLAB will respond by echoing the value of w. That is, it will print w and the matrix of values. In this example, terminating a line with a semicolon character will suppress the output Statement terminators and output suppression A newline terminates a statement unless you are typing in a matrix. Three consecutive periods is the command continuation operator, which signals that you are typing a command which extends across more than one line. For matrices, the open-square-bracket character signals that you are entering a matrix. The process of entering a matrix can extend over more than one line and is terminated with the close-square-bracket character. If you are entering assignment statements into a file, then normally you would terminate them with a semicolon (to suppress output) unless you want the value of some variable to be printed as the file is evaluated Some matrix operators The mathematical notation for the transpose of a matrix w is w T. In MATLAB, the apostophe symbol is used instead. For instance, w will yield the transpose of w. The dimensions of w and w are compatible so the matrices can be mutiplied, using the * operator, as shown below. >> w = [1 2 3; 4 5 6]; >> w*w ans = In the above, notice that the transpose operator has higher precedence than the multiplication operator. Of course, you can also add two compatible matrices using the + operator. There are other more subtle operators. Suppose that you want to square each element in a matrix. There is an operator,.*, called array multiply, that allows you to multiply corresponding elements of two m n matrices to yield a new m n matrix. In the example below, we use the operator to square the elements of w. >> w = [1 2 3; 4 5 6]; >> w.*w ans = Flexible matrix access You can access an element of the matrix w in the previous example by using an expression of the form w(i,j), where i indicates the row and j indicates the column. MATLAB is 3 The function of the semicolon operator is context dependent. In a matrix, it terminates a row. At the end of a line, it suppresses output. The statement terminator is the newline character. The line continuation operator is three consecutive periods The semicolon is a statement terminator in the programming languages C, C++, and JAVA but is an output suppression operator in MATLAB. 4

5 amazingly flexible in allowing you to access information in matrices. For the matrix w, you can treat it as a six-element vector by referencing it using the expression w(:). Type this into the command shell to see what happens. You also have full access to rows and columns in the matrix. For instance, the expression w(2,:) gives you the second row of the matrix and the expression w(:,2) gives you the second column. Type these into the command shell to see what happens. You can delete the second column of matrix w(:,2) by typing >> w(:,2) = []; w = For readability in most of the examples that follow, I will leave out the command-line prompt Loading data via a script It is often very useful to generate data in a traditional language such as C++ or JAVA and then visualize it using MATLAB. There is a very easy way to do this by writing the output data in the form of a MATLAB script. Afterwards, simply executing the script will load the data into MATLAB. The code segment below is a JAVA program that writes data in the form of a MATLAB script. static void printdata(int cyc) { System.out.println("data(:, :, " + cyc + ") = ["); for (int r = 0; r < data.length; r++) { for (int c = 0; c < (data[r].length-1); c++) System.out.print(data[r][c]+" "); System.out.println(data[r][data[r].length-1]+";");} System.out.println("];"); In the above JAVA method, suppose the variable data is a 6 12 array of zeros and ones, representing say the current state of the of a cellular automaton, such as Conway s game of life. Thus the array gets a set of new values on each cycle of the game. Let s assume the method printdata is executed on each cycle in order to print the current state of the game. Possible output for the first cycle is shown below. data(:, :, 1) = [ ; ; ; ; ; ; ]; data(:, :, 2) = [... Notice that JAVA program embedded the output within a MATLAB script where the MAT- LAB variable data is a three-dimensional array. The third dimension holds the cycle number and the first two dimensions hold the state of the two-dimensional array of cellular automata for that cycle. Suppose several cycles of this output are sent to a file named data.m. 5

6 Then from within MATLAB this data can be loaded simply by typing the one-line command data, which is an instruction to evaluate the script named data.m. Once loaded into MATLAB, any number of tools can be used to manipulate, examine, and visualize the data Reading data the old-fashioned way You can also input data into your MATLAB program by opening a file and executing read commands. Suppose you have written a data set of floating point numbers that takes the form of 100 rows of data with 26 numbers in a row, separated by spaces. Suppose that data set is on the file mydata.dat. The four-line script below will read this data into the matrix matdata. 1. fid = fopen( mydata.dat, r ); 2. vecdata=fscanf(fid, %f,inf); 3. status = fclose(fid); 4. matdata=reshape(vecdata,[100 26]); The first line opens the data file mydata.dat for reading and creates a file input stream whose pointer is stored in the variable fid (mnemonic for file id). In the second line, the function fscanf reads formatted data from the file stream specified by fid and takes its name from the roughly equivalent C function. The %f format specifier says to read floating point numbers. The inf specifier says to read until the end of the file. Also, recall that the input data is written on 100 separate lines of 26 numbers. The fscanf function ignores the end of line characters. After reading, the information is stored in the onedimensional array vecdata. The third line closes the file because we have finished reading the information. Closing the file releases the file resource back to the operating system. The fscanf operation read the data in one-dimensional format, but recall that the data is meant to be two-dimensional. Thus, the fourth line uses the function reshape to create a two-dimensional array from the one-dimensional data. 2.2 Vector operations Let us interpret the matrix w as the weight matrix for the first layer of a two-unit neural network with three input-features to each unit. The matrix has two rows and each row codes the three weight values for one unit. Then if we have an input pattern vector p = [1, 0, 0] (represented as a column vector 5 ), we can compute the net-input for this layer with one matrix multiplication as shown below in the last line. p = [1; 0; 0]; w = [1 2 3; 4 5 6]; n = w*p; 5 Vectors are a different kind of object than matrices. When we use vectors and matrices at the same time, we need to find a way to treat them uniformly. The convention is to treat an n-component vector as an n 1 matrix. So, a vector with three components is treated as a 3 1 matrix. Notice that these matrices have n rows and one column. For this reason, they are called column vectors. 6

7 Each component n i of n represents the net input for one neuron in the input layer. Each n i is equivalent to the sum below. N n i = w j,i p j j=1 If we were to compute these sums using for-loops, the interpreter would have to decode and execute six different assignment statements. In this example, the operation of matrix multiplication vectorizes a double-nested for-loop, so that only one statement is needed to calculate it Examining the workspace MATLAB has excellent run-time debugging facilities. In an interpreted language, you get run-time errors that are inconceivable in a compiled language, so excellent run-time debugging is a necessity in an intepreted language. The currrent workspace has three variables which reference matrices. In the MATLAB development environment, you have direct access to inspect and edit the objects in this workspace. Depending on your platform, the workspace inspector is probably under the window menu. When you access this inspector, you will see a list of variable names and the amount of space their associated objects consume. If you click on one of these names, you will be able to inspect the array contents using a spread-sheet-like interface. You can even change the values of entries in a matrix. If you are debugging a neural network program, you can watch the weights evolve using this editor. 2.3 Applying functions to matrix elements To complete the feedforward network computation, let us apply the sigmoidal activation function to each element of the net input array in the previous example. p = [1; 0; 0] w = [1 2 3; 4 5 6] n = w*p a = 1./ (1+exp(-4*n)) This example is the same as the previous except that one more line was added. Let us explain what that line does. Let us work from the innermost expressions, starting with n. First, we premultiplied the matrix n with the scalar 4. Next we applied the exponential function, exp, to the matrix. This has the effect of applying the function to each element of the matrix. Notice, that whereas matrices are signaled by square brackets, function application is signaled parentheses. The next step was to add one to the matrix of results. Notice adding the scalar 1 to a matrix, has the effect of adding one to each element of the matrix. How does this happen? MATLAB converts the scalar 1 to a matrix of ones whose dimensions match the argument on the other side of the operator (in this case +). After this, MATLAB applies the matrix operation of addition. The symbol./ stands for array 7

8 divide and is the division equivalent of.*. The 1 in the numerator again gets converted to a matrix of ones whose dimensions match those on the other side of the operator. Then the matrix of reciprocals is computed Vectorizing a feedforward network for one epoch The earlier example vectorized the presentation of one pattern to the network. If the number of training patterns is small, then we can vectorize the presentation of all the training patterns to the network. For this example, assume that we are training a network to learn a two-input boolean concept such as AND. We are looking at the first layer of the network. The first layer consists of two units, each with two inputs. inputs = [0 0; 0 1; 1 0; 1 1] ; % transposed desiredouts = [ ]; onesvec = [ ]; wts = [.1, -.2;.1, -.1]; biaswts = [.1;.1]; netinputs = (wts * inputs) + (biaswts * onesvec); outputs = 1./ (1 + exp(-4*netinputs)); Notice that wts is a 2 2 matrix and that inputs is a 2 4 matrix. Multiplying wts with inputs yields a 2 4 matrix. The matrix biaswts is 2 1 and onesvec is 1 4. Multiplying these together yields a 2 4 matrix. The matrix netinput is therefore 2 4 and should be interpreted as follows. Each column of the matrix codes the output values of the two units for one input pattern. Since there are four input patterns, there are four columns. 2.4 Defining functions MATLAB uses the call-by-value parameter passing style. Functions can have side-effects if the variables they use are declared global both in the function body and external to the function and also have the same name. When you define a function in MATLAB, it should work with vectorized code. The purpose of this section is to show how to define functions that work with vectorized code. Let s start with a simple example. We shall write a function to compute the logistic sigmoid function, as defined below. logsig(x) = e x MATLAB does not have a built-in logistic sigmoid function. Here is how to implement it. function f = logsig(x) f = 1./ (1 + exp(-x)); Normally, this function is placed in a file named logsig.m. Notice that the function does not have the return statement characteristic of C, C++, or JAVA. The function returns when it reaches the end of its body. The return value is the value of the variable f, which 8

9 was declared at the start of the function. It is also customary not to indent the body of the function. The function is also designed to work either with scalars or with arrays. That is, you should be able to issue the function invocation logsig(1.5) to apply the function 1.5, or the invocation logsig([1 2]) to apply the function to each element of the matrix [1 2]. The next example implements a piecewise linear function and is a bit more tricky to vectorize. MATLAB does not have a built-in symmetric hard-limit function hardlims, which is defined below. { 1 x < 0 hardlims(x) = +1 x 0 MatLab does have the built-in function sign which returns 1, 0, or 1. An example of its use is given below. >> sign([-2 0 2]) ans = This function is similar to the hardlims with one difference. This function returns 0 when its argument is zero and the hardlims function returns 1 which its argument is zero. Here is how to define the hardlims function. It needs to be put on its own file called hardlims.m. In this example, I have included a comment line between the function declaration and the function body. The comment line begins with the % symbol. function f = hardlims(x) % 1 if x >= 0, -1 otherwise f = 2 * (x >= 0) - 1; For this function to work on array arguments, it is necessary to cause the system to create an array of zeros whose dimensions are the same as x. The expression (x >= 0) in the first line of the function body does this before the relational operator is applied. 3 Plotting and visualization The language has convenient and powerful visualization facilities. You can generate data within MATLAB, or from an external program as was illustrated in Section Any plots you generate in MATLAB can be exported into just about any file format you want. (I usually used pdf.) 3.1 Simple plotting The plot command plots two-dimensional graphs. First, let s create a vector y with 101 elements and then plot it. >> y = 0:.1:10; >> plot(y) 9

10 The first line creates a vector whose values range from 0 through 10 in increments of 0.1. (If the increment specifier were left out as in y = 0:10;, the default increment would be 1.) More accurately, y is a matrix. The second line plots this vector as a function of an implicit x ranging from 0 through 100 in increments of 1. That is, the y-values are plotted as a function of their array indices. The plot command operates on vectors and plots a y against an x. This was implicit in the previous example and is made explicit below. >> y = 0:.1:10; >> [rows, cols] = size(y); >> x = rows:cols; >> plot(x,y) In the above, size returns the dimensions of the matrix y. Since the dimensions of a matrix are given in rows an columns, the size function returns a pair of values. One can use a componentwise assignment statement to save both values. This componentwise assignment statement gives rows the value 1 and cols the value 101. The next line creates a vector x with a default increment of 1. Compare this with the creation of y with an explicit increment of 0.1. Finally, the plot command explicitly plots y as a function of x. A useful example Suppose you want to graph the logistic sigmoid function over the interval 5 to +5. The two lines below do this using a step size for the x-axis of 0.2. >> x = -5:0.2:5; >> plot(x, 1./(1+exp(-x))); Application to neural networks It is very easy to plot the sum-of-squared error (SSE) as a function of training epoch, as shown in the example below. In this example, we train the network for 1000 epochs unless the SSE drops below In this case, we break from the for-loop. 6 for epoch=1: SSE(epoch) = sum(error.* error); if((sse(epoch)<.02)) break; end end plot(sse); The variable error is assumed to hold a vector of error values for the n training patterns in one epoch of training. If we square those error values and add them up, then we have the SSE for that particular training epoch. We save these values in the dynamically growing array 7 SSE. In MATLAB, when storing a value in an array, if you use an array index that is 6 This example illustrates the syntax of for statements and if statements. Notice that both statements terminate with an end. Also, the for statement allows a break. Finally, the scope of the iteration variable epoch continues beyond the end of the for statement. 7 If you are in a debugging cycle and you reload this file, then you should include a clear statement at the beginning of the file. You need to erase the old SSE array from the system. 10

11 larger than the number of elements in the array, the array grows so that it is large enough to handle the index. In JAVA, you would get an array index out-of-bounds exception. In C or C++, your program behavior would be undefined. Once it is computed, plotting the SSE is so easy it is mind boggling. Of course, we should put labels on the graph axes and give it a title, as shown below. plot(sse); xlabel( Epoch ); ylabel( SSE ); title( SS error for backprop ); If you want to print the value of a variable in a title, then use the more complex variant below. title([ SS error for, num2str(epoch), epochs of bp ]); In this variant, title accepts a vector of strings. Notice, that the value of the variable epoch is converted to a string D Plots The command plot3 allows you to plot data in three dimensions. The script below loads the data illustrated in Section and then plots it in three dimensions using the plot3 command. data; hold on for cyc=1:50, [x,y] = find(data(:,:,cyc)); z=zeros(length(y),1)+cyc; plot3(z,x,y,. ) axis([ ]) end; In the above, we assume that 50 frames or cycles of data have been generated. The 3D plot is generated in a loop of 50 iterations where each iteration plots one frame of data on the graph using the command plot3. The hold on command says to superimpose the data from successive plots, rather than to erase the graph for each new plot. For a given cycle of the life simulation, the command find obtains the x and y coordinates of the non-zero elements of the two-dimensional matrix data(:, :, cyc). The list of x coordinates goes into the x vector, and similarly for the y coordinates. Since x and y are vectors of the same length, we also need a z vector of the same length to give to the plot3 command. To do this, we create a vector of zeroes whose length matches y. The we add a scalar cyc to this vector. In MATLAB, this adds the scaler to each element of the vector, yielding a vector whose length is the same as y and whose components are all equal to cyc. Next, we issue the plot3 command. We plot the z dimension on the x axis of plot3 because we want the progress of time to be depicted on the x access of the plot. Finally, we use the axis command to say that we want dimensions of the x, y, and z axes to vary from , , and , respectively. These values match the dimensions of the plotted data. 11

12 3.3 Surface plots You can use a surface plot to plot the values in a two-dimensional matrix. Let s apply this to a neural network that has one ouput unit but has been trained on four input patterns. If we look at that unit for one epoch of training, it will have four values corresponding to each of the input patterns. If we store these values in a matrix across all epochs of training, then we can plot the ouput values as a function of pattern and training epoch. The example below illustrates how to do this. The matrix history is incrementally updated to hold the output values of the units for the current training epoch. for epoch=1: history(:,epoch)=outputsl2(:); SSE(epoch) = sum(error.* error); if((sse(epoch)<.02)) break; end end plot(sse); figure; surf(history); view([45,45]); The command surf(history) creates a surface plot of the history matrix. This surface plot is very useful because it shows you how the output units change their response to the input patterns as a function of training. It vividly displays the network s change in behavior as a result of the learning process. The command figure tells MATLAB to plot the results in a new figure and do not overwrite the results in the SSE figure. The command view([45,45]) sets the viewing angle. You can play with these parameters to get a good viewing angle. Of course, you will want to annote the plot as illustrated below. surf(history); view([45,45]); xlabel( Epoch ); ylabel( Pattern ); zlabel( Activation ); title( Activation to patterns as a function of training ); 3.4 Other plotting commands In the earlier examples, MATLAB chose bounds for the x and y axes automatically. You can specify this explicityly with the AXIS command. You can put several graphs within the same figure using the subplot command. You can plot error bars using the errorbar command in conjunction with hold. A Appendix: Matrix notation A 2 by 3 matrix has two rows and three columns. An m n matrix has m rows and n columns. With these conventions, the elements of an m n matrix, A, would be written as 12

13 shown below. a 1,1 a 1,2 a 1,n a 2,1 a 2,2 a 2,n A a m,1 a m,2 a m,n If m equals n, then we have a square matrix. A square matrix has the same number of rows and columns. Further, a square matrix has a diagonal. This is the set of matrix locations a i,i. A very important square matrix is the identity matrix, I, which has ones along the diagonals and zeros everywhere else, as shown below I A.1 Matrix multiplication This convention of describing matrix dimensions eases the problem of keeping track of whether two matrices may be multiplied together to produce a new matrix and what the resulting matrix dimensions will be. A matrix A can be multiplied with a matrix B if the number of columns in A is equal to the number of rows in B. Suppose that A is an m n matrix and B is an n o matrix. Then A can be multipled with B, written AB. The resulting product matrix will have dimensions m o. Matrix B cannot be multiplied with A unless o is equal to m. Although scalar multiplication is commutative, matrix multiplication is not in general commutative. Matrix multiplication is associative and distributive. We can easily define how to compute the elements of the product matrix AB. Element ij of matrix AB is computed by taking the inner product of row i in matrix A and column j in matrix B. The inner product is not defined if row i does not have the same number of elements as column j. This is why the number of columns of A must equal the number of rows of B. The identity matrix has special properties with respect to matrix multiplication. Multiplying a square matrix, A, with the identity matrix or multiplying the identity matrix with A both yield the original matrix A. That is, A.2 Definition of transpose AI = IA = A (1) The notation A T refers to a matrix generated from matrix A by reversing the order of the subscripts of each of the elements. If A is an m n matrix, then A T (read A transpose ) is an n m matrix. When deriving results, there are a number of useful facts about the transpose of a matrix. 1. The transpose of the identity matrix is itself. I = I T 13

14 2. The transpose of the transpose of a matrix is the original matrix. A = (A T ) T 3. The transpose of the product of two matrices is the transpose of the second matrix multiplied with the transpose of the first matrix. (AB) T = B T A T 14

Introduction to MATLAB

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

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 MATLAB, SIMULINK, AND THE COMMUNICATION TOOLBOX

INTRODUCTION TO MATLAB, SIMULINK, AND THE COMMUNICATION TOOLBOX INTRODUCTION TO MATLAB, SIMULINK, AND THE COMMUNICATION TOOLBOX 1) Objective The objective of this lab is to review how to access Matlab, Simulink, and the Communications Toolbox, and to become familiar

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

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

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

What is MATLAB and howtostart it up?

What is MATLAB and howtostart it up? MAT rix LABoratory What is MATLAB and howtostart it up? Object-oriented high-level interactive software package for scientific and engineering numerical computations Enables easy manipulation of matrix

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

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

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

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

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

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

UNIVERSITI TEKNIKAL MALAYSIA MELAKA FAKULTI KEJURUTERAAN ELEKTRONIK DAN KEJURUTERAAN KOMPUTER

UNIVERSITI TEKNIKAL MALAYSIA MELAKA FAKULTI KEJURUTERAAN ELEKTRONIK DAN KEJURUTERAAN KOMPUTER UNIVERSITI TEKNIKAL MALAYSIA MELAKA FAKULTI KEJURUTERAAN ELEKTRONIK DAN KEJURUTERAAN KOMPUTER FAKULTI KEJURUTERAAN ELEKTRONIK DAN KEJURUTERAAN KOMPUTER BENC 2113 DENC ECADD 2532 ECADD LAB SESSION 6/7 LAB

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

Experiment 1: Introduction to MATLAB I. Introduction. 1.1 Objectives and Expectations: 1.2 What is MATLAB?

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

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

Introduction to Matlab

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

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

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

Matlab Tutorial: Basics

Matlab Tutorial: Basics Matlab Tutorial: Basics Topics: opening matlab m-files general syntax plotting function files loops GETTING HELP Matlab is a program which allows you to manipulate, analyze and visualize data. MATLAB allows

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

A very brief Matlab introduction

A very brief Matlab introduction A very brief Matlab introduction Siniša Krajnović January 24, 2006 This is a very brief introduction to Matlab and its purpose is only to introduce students of the CFD course into Matlab. After reading

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

Introduction to MATLAB

Introduction to MATLAB Introduction to MATLAB The Desktop When you start MATLAB, the desktop appears, containing tools (graphical user interfaces) for managing files, variables, and applications associated with MATLAB. The following

More information

1 Overview of the standard Matlab syntax

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

EGR 111 Introduction to MATLAB

EGR 111 Introduction to MATLAB EGR 111 Introduction to MATLAB This lab introduces the MATLAB help facility, shows how MATLAB TM, which stands for MATrix LABoratory, can be used as an advanced calculator. This lab also introduces assignment

More information

Computer Programming ECIV 2303 Chapter 1 Starting with MATLAB Instructor: Dr. Talal Skaik Islamic University of Gaza Faculty of Engineering

Computer Programming ECIV 2303 Chapter 1 Starting with MATLAB Instructor: Dr. Talal Skaik Islamic University of Gaza Faculty of Engineering Computer Programming ECIV 2303 Chapter 1 Starting with MATLAB Instructor: Dr. Talal Skaik Islamic University of Gaza Faculty of Engineering 1 Introduction 2 Chapter l Starting with MATLAB This chapter

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

MATLAB Lesson I. Chiara Lelli. October 2, Politecnico di Milano

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

MATLAB BASICS. M Files. Objectives

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

What is MATLAB? It is a high-level programming language. for numerical computations for symbolic computations for scientific visualizations

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

CSCI 6906: Fundamentals of Computational Neuroimaging. Thomas P. Trappenberg Dalhousie University

CSCI 6906: Fundamentals of Computational Neuroimaging. Thomas P. Trappenberg Dalhousie University CSCI 6906: Fundamentals of Computational Neuroimaging Thomas P. Trappenberg Dalhousie University 1 Programming with Matlab This chapter is a brief introduction to programming with the Matlab programming

More information

Creates 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.

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

FreeMat Tutorial. 3x + 4y 2z = 5 2x 5y + z = 8 x x + 3y = -1 xx

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

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

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

Introduction to MATLAB

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

Ordinary Differential Equation Solver Language (ODESL) Reference Manual

Ordinary Differential Equation Solver Language (ODESL) Reference Manual Ordinary Differential Equation Solver Language (ODESL) Reference Manual Rui Chen 11/03/2010 1. Introduction ODESL is a computer language specifically designed to solve ordinary differential equations (ODE

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

PART 1 PROGRAMMING WITH MATHLAB

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

STAT 391 Handout 1 Making Plots with Matlab Mar 26, 2006

STAT 391 Handout 1 Making Plots with Matlab Mar 26, 2006 STAT 39 Handout Making Plots with Matlab Mar 26, 26 c Marina Meilă & Lei Xu mmp@cs.washington.edu This is intended to help you mainly with the graphics in the homework. Matlab is a matrix oriented mathematics

More information

SECTION 1: INTRODUCTION. ENGR 112 Introduction to Engineering Computing

SECTION 1: INTRODUCTION. ENGR 112 Introduction to Engineering Computing SECTION 1: INTRODUCTION ENGR 112 Introduction to Engineering Computing 2 Course Overview What is Programming? 3 Programming The implementation of algorithms in a particular computer programming language

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

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

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

Matrices. Chapter Matrix A Mathematical Definition Matrix Dimensions and Notation

Matrices. Chapter Matrix A Mathematical Definition Matrix Dimensions and Notation Chapter 7 Introduction to Matrices This chapter introduces the theory and application of matrices. It is divided into two main sections. Section 7.1 discusses some of the basic properties and operations

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

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

Introduction to Matlab

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

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

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

An Introduction to MATLAB

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

The Warhol Language Reference Manual

The Warhol Language Reference Manual The Warhol Language Reference Manual Martina Atabong maa2247 Charvinia Neblett cdn2118 Samuel Nnodim son2105 Catherine Wes ciw2109 Sarina Xie sx2166 Introduction Warhol is a functional and imperative programming

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

MAT 275 Laboratory 2 Matrix Computations and Programming in MATLAB

MAT 275 Laboratory 2 Matrix Computations and Programming in MATLAB MATLAB sessions: Laboratory MAT 75 Laboratory Matrix Computations and Programming in MATLAB In this laboratory session we will learn how to. Create and manipulate matrices and vectors.. Write simple programs

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

1 Introduction to MATLAB

1 Introduction to MATLAB 1 Introduction to MATLAB 1.1 General Information Quick Overview This chapter is not intended to be a comprehensive manual of MATLAB R. Our sole aim is to provide sufficient information to give you a good

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

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

Matlab Tutorial. The value assigned to a variable can be checked by simply typing in the variable name:

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

An Introduction to Numerical Methods

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

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. Devon Cormack and James Staley

MATLAB. Devon Cormack and James Staley MATLAB Devon Cormack and James Staley MATrix LABoratory Originally developed in 1970s as a FORTRAN wrapper, later rewritten in C Designed for the purpose of high-level numerical computation, visualization,

More information

Introduction to Matlab

Introduction to Matlab Introduction to Matlab The purpose of this intro is to show some of Matlab s basic capabilities. Nir Gavish, 2.07 Contents Getting help Matlab development enviroment Variable definitions Mathematical operations

More information

Laboratory 1 Introduction to MATLAB for Signals and Systems

Laboratory 1 Introduction to MATLAB for Signals and Systems Laboratory 1 Introduction to MATLAB for Signals and Systems INTRODUCTION to MATLAB MATLAB is a powerful computing environment for numeric computation and visualization. MATLAB is designed for ease of use

More information

ELEN E3084: Signals and Systems Lab Lab II: Introduction to Matlab (Part II) and Elementary Signals

ELEN E3084: Signals and Systems Lab Lab II: Introduction to Matlab (Part II) and Elementary Signals ELEN E384: Signals and Systems Lab Lab II: Introduction to Matlab (Part II) and Elementary Signals 1 Introduction In the last lab you learn the basics of MATLAB, and had a brief introduction on how vectors

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

JME Language Reference Manual

JME Language Reference Manual JME Language Reference Manual 1 Introduction JME (pronounced jay+me) is a lightweight language that allows programmers to easily perform statistic computations on tabular data as part of data analysis.

More information

An array is a collection of data that holds fixed number of values of same type. It is also known as a set. An array is a data type.

An array is a collection of data that holds fixed number of values of same type. It is also known as a set. An array is a data type. Data Structures Introduction An array is a collection of data that holds fixed number of values of same type. It is also known as a set. An array is a data type. Representation of a large number of homogeneous

More information

Programming 1. Script files. help cd Example:

Programming 1. Script files. help cd Example: Programming Until now we worked with Matlab interactively, executing simple statements line by line, often reentering the same sequences of commands. Alternatively, we can store the Matlab input commands

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

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

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

1 Introduction to MATLAB

1 Introduction to MATLAB 1 Introduction to MATLAB 1.1 Quick Overview This chapter is not intended to be a comprehensive manual of MATLAB R. Our sole aim is to provide sufficient information to give you a good start. If you are

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

Chapter 2. MATLAB Fundamentals

Chapter 2. MATLAB Fundamentals Chapter 2. MATLAB Fundamentals Choi Hae Jin Chapter Objectives q Learning how real and complex numbers are assigned to variables. q Learning how vectors and matrices are assigned values using simple assignment,

More information

Eng Marine Production Management. Introduction to Matlab

Eng Marine Production Management. Introduction to Matlab Eng. 4061 Marine Production Management Introduction to Matlab What is Matlab? Matlab is a commercial "Matrix Laboratory" package which operates as an interactive programming environment. Matlab is available

More information

QUICK INTRODUCTION TO MATLAB PART I

QUICK INTRODUCTION TO MATLAB PART I QUICK INTRODUCTION TO MATLAB PART I Department of Mathematics University of Colorado at Colorado Springs General Remarks This worksheet is designed for use with MATLAB version 6.5 or later. Once you have

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

Digital Image Analysis and Processing CPE

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

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

MATLAB BASICS. < Any system: Enter quit at Matlab prompt < PC/Windows: Close command window < To interrupt execution: Enter Ctrl-c.

MATLAB BASICS. < Any system: Enter quit at Matlab prompt < PC/Windows: Close command window < To interrupt execution: Enter Ctrl-c. MATLAB BASICS Starting Matlab < PC: Desktop icon or Start menu item < UNIX: Enter matlab at operating system prompt < Others: Might need to execute from a menu somewhere Entering Matlab commands < Matlab

More information

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

MATLAB Fundamentals. Berlin Chen Department of Computer Science & Information Engineering National Taiwan Normal University

MATLAB Fundamentals. Berlin Chen Department of Computer Science & Information Engineering National Taiwan Normal University MATLAB Fundamentals Berlin Chen Department of Computer Science & Information Engineering National Taiwan Normal University Reference: 1. Applied Numerical Methods with MATLAB for Engineers, Chapter 2 &

More information

MatLab Just a beginning

MatLab Just a beginning MatLab Just a beginning P.Kanungo Dept. of E & TC, C.V. Raman College of Engineering, Bhubaneswar Introduction MATLAB is a high-performance language for technical computing. MATLAB is an acronym for MATrix

More information

Computer Vision. Matlab

Computer Vision. Matlab Computer Vision Matlab A good choice for vision program development because Easy to do very rapid prototyping Quick to learn, and good documentation A good library of image processing functions Excellent

More information

Introduction to Engineering gii

Introduction to Engineering gii 25.108 Introduction to Engineering gii Dr. Jay Weitzen Lecture Notes I: Introduction to Matlab from Gilat Book MATLAB - Lecture # 1 Starting with MATLAB / Chapter 1 Topics Covered: 1. Introduction. 2.

More information

Introduction to Programming in C Department of Computer Science and Engineering. Lecture No. #29 Arrays in C

Introduction to Programming in C Department of Computer Science and Engineering. Lecture No. #29 Arrays in C Introduction to Programming in C Department of Computer Science and Engineering Lecture No. #29 Arrays in C (Refer Slide Time: 00:08) This session will learn about arrays in C. Now, what is the word array

More information