ELEN E3084: Signals and Systems Lab Lab II: Introduction to Matlab (Part II) and Elementary Signals
|
|
- Basil Cain
- 6 years ago
- Views:
Transcription
1 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 are defined and represented in MATLAB. In this lab you will learn how to further manipulate these quantities, and use them to represent signals. We will also depend our understanding on the use of complex numbers in MATLAB, which will be quite handy when we start representing signals in the frequency domain. A great feature of MATLAB is the wealth of visualization tools that are available to us. This is one of the features that makes MATLAB so appealing when compared with many programming languages. We will learn how to use some of these tools to plot various signals, and even create high-quality plots for presentations and publications. Before we begin we will start again the diary function which will capture all our commands. Go the lab2 directory using the cd command the same way as in UNIX. Then type: >> diary on; Again, note that the goal of these labs is for you to tinker and play with the concepts that are introduced, in addition to the completion of the required tasks. Show the diary file at the end of the session to a TA or LA, so that she/he can assess the extent of your work. 2 Complex numbers We have already seen that MATLAB has predefined the imaginary unit. The default variables i and j are built-in and hold the value of the imaginary unit or simply 1 (be careful not to use i or j as your own variables if you want to use complex numbers). For example all following statements define the same complex number. >> 2 + 3*i i >> 2 + 3*j i 1
2 >> 2 + 3i i >> 2 + 3j i Notice that you don t need the multiplication symbol * as MATLAB can parse the expression either way. Once we enter a complex number then pretty much all the relevant elementary functions presented in the previous lab can be used. For example even the complex logarithm is defined as we see in: >> x = 2 + 3*i; >> log(x) i Moreover, given a complex number z the functions real(z), imag(z), conj(z), abs(z) and angle(z) calculate the real part, the imaginary part, the conjugate, the absolute value and the angle of z respectively, where the angle is in radians, and defined in the interval ( π, π). For example for z = 1 j we have Re{z} = 1, Im{z} = 1, z = 1 + j, z = 2 and z = π/4. Now if we try to reproduce the same result with MATLAB we will get: >> z = 1 - j; >> disp([ real part:,num2str(real(z))]); real part: 1 >> disp([ imag part:,num2str(imag(z))]); imag part: -1 >> disp([ conjugate:,num2str(conj(z))]); conjugate: 1+1i >> disp([ abs value:,num2str(abs(z))]); abs value: >> disp([ angle:,num2str(angle(z))]); angle: The angle is in radians, so if you want it in degrees you just need to multiply by 18/π. 2
3 3 Vectors 3.1 Definition of vectors We have already seen how to create vectors in the previous lab. Here we further expand on what can be done. Recall some of the various ways you can create a vector row or column vector. Typing >> x = [ pi] or >> x = [1,2.5,3,pi] both give: x = As seen before the transpose operator {. } allows you to convert a column into a row vector, and vice-versa. >> x Vectors can be real or complex but numerical and string values cannot be mixed in the same vector 1. For example a complex vector can be defined as: >> z = [1 -j 3+2i] z = i i 1 For that we have to use cell arrays which is outside of the scope of this lab 3
4 If we want to define vectors straight in the column form instead of using the transpose operator we can concatenate the values using semicolons. >> x = [1;-12.3;pi;sqrt(2)] x = Creating vectors by using the above procedures can be quite tedious, and not practical if you need to create long vectors. The colon operator : allows you to do this quite easily. For example >> x=:1 x = gives you a row vector with all the values from up to 1, spaced by 1. You have already seen this construction when using for loops in the first lab session. You can modify the spacing between the various entries with an extra parameter >> x=:.3:3 x = Columns 1 through Columns 9 through Furthermore the spacing can be a negative number, giving you a decreasing sequence >> x=4:-.5:2 4
5 x = We will use all these constructions extensively to create and manipulate signals. 3.2 Manipulation of vectors We can select the k-th element of a vector using subscripted indexing. For example: >> a = [3;-5;12;] a = >> a(2) -5 >> a(3) 12 Notice the use of parenthesis and that elements are indexed starting at 1. The keyword end, first seen in the for and if constructs, can be used to select the last element of a vector, row or column. >> b = [-5,-2,,,12] b = >> b(end) 12 As we seen, in its simplest form the colon operator can generate an index vector. example: For >> idx1 = 3:6 idx1 =
6 This means that we can use the colon operator to slice a vector which means to select a part of it. For example: >> c = [-3,2,,2,5,7,9] c = >> c(3:6) or using the above defined idx1 >> c(idx1) Notice that when we use the colon operator for indexing we don t have to use square brackets. To Do 1 create a row vector x = (2, 3, 5, 7, 11, 13, 17, 19, 23, 29) in MATLAB. Now use the colon operator to display only the even entries of the vector, that is, the output should be the vector (3, 7, 13, 19, 29). Now do the same thing but display the output in reverse order, that is, the output should be (29, 19, 13, 7, 3) We can find the indices of the elements of a vector that match a certain logical statement using the find command. For example we can find the positive elements of the vector a using: >> a = [-2,3,-1,5,7] a = >> idx = find(a>) idx = This means the 2nd, 4th and 5th element of the vector a are positive (i.e., satisfy the statement a(i) >, for i = 2, 4, 5). Now if we use the variable idx we can see only the values of the elements that are positive: >> a(idx)
7 There is a shortcut way of doing the same thing, by simply typing a(a>). This shows you another way of indexing elements of a vector in MATLAB. In this case b=(a>) outputs a binary vector with the same length as a, and when typing a(b) you get the entries of the vector corresponding to the entries of b that are 1. Try it! Finally we can selectively delete elements of a vector using the empty square bracket operator. We can use all the methods to select elements such us subscripted indexing or slicing and just assign the empty element which is the empty square brackets. For example: >> b = [2,4,2,1,6,7,4,6] b = >> idx = find(b<=2) idx = >> b(idx) = [] b = As you see we found the indices of the elements of b that are smaller or equal to 2 and we deleted them from b. 3.3 Matrices Actually vectors are just a particular type of matrices, with either one row or one column. Matrices are extremely useful in signal processing applications. These can be used to represent images, transformations, etc. All the things that we learned so far about vectors apply to matrices as well, but instead you have to deal with two indexes instead of one. Matrices can be created as a concatenation of vectors. For example >> A=[1:4;5:8;9:12] A = or >> A=[1 2;3 4] 7
8 A = We often need to create special large vectors/matrices automatically since explicitly typing every element would be tedious. Vectors/matrices consisting of only zeros or ones turn out to be particularly useful in MATLAB. We can generate a row vector of zeros or ones using the commands: >> disp(zeros(1,5)) >> disp(ones(1,3)) If we need column versions we can get them either with transposition or by using: >> disp(zeros(5,1)) >> disp(ones(3,1)) A matrix of zeros or ones with n rows and m columns can be also easily created, for example >> A=zeros(4,3) A = yields a matrix of zeros, with 4 rows and three columns. 8
9 3.4 Arithmetic operations with vectors and matrices Arithmetic operations in MATLAB follow the usual matrix arithmetic rules. That is, you can multiply a scalar by a matrix or vector (every entry in the vector/matrix is multiplied by the scalar), and operations between vectors or matrices require that the sizes match properly, as you have learn in linear algebra (for addition and subtraction the vectors/matrices need to be of the same size, and for multiplication the number of columns of the first operand much match the number of rows of the second operand). Addition and subtraction is defined as an element-by-element operation: >> a = [1,3,-2]; >> b = [,2,1]; >> a + b >> a - b The multiplication, division and power operators, however need special attention. Normally these follow the rules of matrix multiplication, but if preceded by a dot these are performed element-by-element as illustrated below: >> a = [1,3,-2]; >> b = [,2,1]; >> b.* a 6-2 >> b./ a >> b.^ a 8 1 In the case of a scalar and a vector: >> a = [1,3,-2]; >> b = 2; >> a + b 9
10 3 5 >> a - b >> a.* b >> a./ b >> a.^ b Functions on vectors Most of the functions we have seen so far are vectorized which means that they can accept a vector as an input argument and perform their operation on each element separately. So for example: >> x = [1,3,2.1,exp(1)] x = >> log(x) >> sin(x) >> imag(x) We have to note though that there are some functions which have special meaning when operate on vectors. Assuming a vector a then the length(a) gives the number of elements whereas the sum(a) and prod(a) calculate the sum and product of its elements. The function diff(a) calculates the difference between each consecutive element. Assuming a column vector then flipud(a) reverses it upside-down and assuming a row vector then fliplr(a) reverses it left-right. For example: >> a = [1,3,2,5]; 1
11 >> disp(length(a)) 4 >> disp(sum(a)) 11 >> disp(prod(a)) 3 >> disp(diff(a)) >> disp(mean(a)) 2.75 >> disp(var(a)) >> disp(fliplr(a)) Notice that the diff command returns a vector with length one element less than the original length (3 instead of 4 elements in this case). To Do 2 Generate vectors. We will now make use of the commands we just learned in order to generate some specific vectors. Note that you shouldn t use any loops such as for or while just the colon operator and elementary functions. Show the LA or TA the code that generates each of the row vectors below: 1, 3, 5, 7, 9, 11 5, 5, 5, 5, 5 4-3i, 2-2i, - 1i, -2 4, 16, 64, Plotting and Graphics 4.1 Plots and sublots MATLAB makes it possible to create sophisticated plots. Using simple commands we are able to visualize elementary signals and even include them in our reports. Here we will only scratch the surface of the all possibilities. 11
12 Figure 1: A simple plot of a sine where the independent variables are the vector indices The basic idea of plotting in MATLAB is very simple. Assuming that the independent x and dependent y variables are stored in vectors of the same length then the plot(x,y) command plots the pairs of points in the two-dimensional plane. By default plot connects the points by straight line segments but options like dashed lines or no lines at all are possible (use the help command to learn more). If the plotting is successful, a window pops up containing the plot. Finally, using the menus on the window the plot can be printed or saved. If y is a vector, then the simplest plotting command is plot(y). In this case the vector elements are the dependent variables and the indices of the vector (in increasing order) are the independent variables. Here is an example with the resulting plot shown in figure 1: >> x = :pi/2:4*pi; >> y = sin(x); >> plot(y) Independent variables are included using the command plot(x,y) where the vector x contains the independent variables and the vector y (of the same length) contains the dependent variables. In this fashion more plots can be included in one figure by putting the corresponding pairs of vectors inside the parenthesis of the plot command. This is illustrated in the figure 2 and the code below: >> x = :pi/3:3; >> y1 = sin(x); >> y2 = cos(x); >> y3 = y1.^2; >> plot(x,y1,x,y2,x,y3) >> axis tight 12
13 Figure 2: A plot of three functions with independent variables More plots in the same figure look often neater by using the subplotting option of MATLAB. Here each plot command is preceded by the subplot command. The subplot and plot commands are separated by a comma. We will use a simple subplot command we can place plots vertically. The command is given by subplot(m,i,k) where m and k are integers and (for us) the middle number is always 1. The number m refers to the total number of plots and k refers to the indices of particular plots. Here is an example of the functions plotted in figure 2 but this time in figure 3 using subplots. >> x = linspace(,4*pi,3); >> y1 = sin(x); >> y2 = cos(x); >> y3 = y1.^2; >> subplot(3,1,1) >> plot(x,y1) >> axis tight >> subplot(3,1,2) >> plot(x,y2) >> axis tight >> subplot(3,1,3) >> plot(x,y3) >> axis tight Notice a function you haven t seen before linspace. Use the help command to learn what it does. 13
14 Figure 3: A plot of three functions with independent variables using three subplots 4.2 Miscellaneous commands Annotating your plots is essential to make then understandable (otherwise you quickly forgot what is what in the plot). Adding a title, x- and y-axis labels is easy to do using the commands title, xlabel and ylabel respectively. Adding a legend with names is also easy using the command legend. We can also manipulate the shape of the axis by using the axis command using a variety of arguments (see help axis for more). For better readability we can also make visible a grid using the grid on command. We can see those commands in action the following snippet of code which generates the Figure 4: >> t = linspace(,2,5); >> v = exp(-3*t); >> plot(t,v) >> grid on >> title( Exponential decay ) >> xlabel( Time (sec) ) >> ylabel( Voltage (mv) ) >> axis square Lastly two other useful commands are the figure command and the close command. With figure we tell MATLAB to create a new figure so that we don t overwrite any existing one. This way we can have multiple figures displayed on the screen at once. Using close we tell MATLAB to close the current figure and with close all we can close all the open figures. 14
15 1 Exponential decay Voltage (mv) Time (sec) Figure 4: Demonstrating miscellaneous plotting commands 4.3 Exporting plots for publications After using MATLAB s powerful plotting tools you often want to export your graphics to use them in reports or other publications. There are various ways of doing this for example using the print command. Another option is to use a series of specialized functions that were released with the same purpose, and are available at digest/december/export.shtml. You should download the four functions exportfig, previewfig, applytofig and restorefig and save them under the /lab2 directory. Now we will go through an example which will generate the plot on figure 5. To Do 3 Export a plot. We will now revisit the plot of figure 2 but this time we will export it using the exportfig function. Type the following code on the command prompt: >> x = linspace(,4*pi,3); >> y1 = sin(x); >> y2 = cos(x); >> y3 = y1.^2; >> plot(x,y1,x,y2,x,y3) >> grid on >> axis tight 15
16 Plot of sin, cos and sin 2 sin cos sin Figure 5: Example using the expfig function >> axis([ 4*pi ]) >> legend( sin, cos, sin^2 ); >> title( Plot of sin, cos and sin^2 ) Using the mouse resize the plot window so that it looks shorter in height as in figure 5. Then go the /lab2 directory using the cd command. Export the plot using the following commands and submit the expfig.eps file. >> set(gcf, paperunits, centimeters ); >> exportfig(gcf, expfig.eps, bounds, tight, width,8.5, linestylemap, bw ); The benefits of using this approach might not be apparent now but one can appreciate them when including plot in papers using L A TEX. For example this lab manual is written in L A TEX and figure 2 was created using the standard MATLAB exporting mechanism while figure 5 was created using exportfig. Notice that in figure 5 we managed to preserve the aspect ratio of the plot and that the line widths and font sizes are not scaled down. Also notice that the colors have been automatically substituted by different line types to make them legible in black and white. Lastly using the width parameter we were able to specify the exact width of the figure to 8.5cm which is the standard width for a two-column conference paper. 16
17 5 Elementary signals 5.1 Unit impulse, unit step and ramp functions Most of the theory presented in the Signals & Systems course examines the behavior of continuous-time signals and systems. MATLAB can use special, so-called symbolic variables to represent and manipulate continuous signals and systems (another software package called Mathematica has much more developed symbolic capabilities). When doing non-symbolic manipulations however MATLAB is limited to use discretized versions on signals. Using the vector notation and the plotting commands we introduced it is now easy to create and visualize signals. In fact we have already done that when we created sines and cosines for our plotting examples. Now we will write two simple functions to generate the unit step and ramp signals. To Do 4 Write and save in m-files under the /lab2 directory the following two functions (remember that the m-file should have the same name as the function definition plus the extension.m): The unit step function is defined as: function y = us(t) %US Unit step % y = us(t) % t: time index % y: signal y = (t >= ); us[t] = And the unit ramp function is defined as: ur[t] = { 1, t, t < { t, t, t < Write your own code to implement the ramp function and show it to your TA (LA) (the ramp function should be very similar to the unit step function, and you should be able to apply it to a vector as well). Now it is easy to create other signals using the functions we just wrote. For example: >> t = -5:.1:5; 17
18 Figure 6: A signal created using the unit step and unit ramp functions >> y = us(-t+2).* ur(t); >> plot(t,y) >> grid on >> axis([ ]) >> set(gcf, paperunits, centimeters ); >> exportfig(gcf, elem1.eps, bounds, tight, width,8.5, linestylemap, bw ); gives the plot in figure 6, and exports a.eps file. Using our functions it s now easy to visualize time shifting and time reversal. For example replacing above y=us(-t+2).* ur(t) by y=us(t+2).* ur(-t) gives the time-reversed signal. To make it even more intuitive create a vectorized function tinyramp that evaluates the function tinyramp(t) = t(u(t) u(t 2)). Now use this function to plot the following signals: tinyramp(2t 4), tinyramp(3 t) and tinyramp((t 1) 2 ). Show your code and plots in.eps format to the TA. To Do 5 We will see in class that most signals can be approximated over a finite interval using sums of sines and cosines (this is called the Fourier series). In fact the signal of Figure 6 can be expressed over the interval (, 4) as ( πn ) π 2 n 2 (( 1)n 1) cos 2 t 2 ( πn ) πn ( 1)n sin 2 t n=1. 18
19 As it is not possible to compute an infinite sum in MATLAB we will consider only the first N terms in the summation above. Write a function fourier approx that takes as argument a vector t of time indexes, and N, the number of elements in the summation to be included. Plot the true function and the approximation in the same axes, for various values of N and comment on the effect of N and the quality of the approximation. Note the ringing effect at t = 2 - This is called the Gibb s effect. What happens to the ringing when N increases? Show your code and plots to the TA. To Do 6 Average length of ones. Now we will write a function which will test our knowledge on vector manipulation. Assuming a random sequence of zeros and ones we should calculate the average length of contiguous ones. For example given a vector: >> a = [,,,,1,1,,1,,]; our function should be named avgones and give the following result: >> avgones(a) 1.5 As we see the vector has two consecutive ones at indices 5,6. This segment thus has length 2. It also has a one at index 8 which obviously has length 1. This means that the average length of consecutive ones in the vector a is (2 + 1)/2 = 1.5. The trick here is to use the diff and find commands. Obviously the cases of a vector full of ones should give as result the length of the vector and the case of a vector full of zeros should give as result zero. Lastly notice that using the same function we can calculate the average length of zeros using the command: >> a = [,,,,1,1,,1,,]; >> avgones(~a) >> (4+1+2)/ Save the function using the filename avgones.m in the directory /lab2 and submit it. 19
20 At this point you should turn off the diary function we started in the beginning of this lab session. You can do that by typing: >> diary off; This will create the diary file that contains all the commands you typed in the command prompt as well as all the output they generated. You should show the LA or TA the diary file. 2
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 informationA Guide to Using Some Basic MATLAB Functions
A Guide to Using Some Basic MATLAB Functions UNC Charlotte Robert W. Cox This document provides a brief overview of some of the essential MATLAB functionality. More thorough descriptions are available
More informationDr Richard Greenaway
SCHOOL OF PHYSICS, ASTRONOMY & MATHEMATICS 4PAM1008 MATLAB 3 Creating, Organising & Processing Data Dr Richard Greenaway 3 Creating, Organising & Processing Data In this Workshop the matrix type is introduced
More informationA 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 informationMATLAB Tutorial EE351M DSP. Created: Thursday Jan 25, 2007 Rayyan Jaber. Modified by: Kitaek Bae. Outline
MATLAB Tutorial EE351M DSP Created: Thursday Jan 25, 2007 Rayyan Jaber Modified by: Kitaek Bae Outline Part I: Introduction and Overview Part II: Matrix manipulations and common functions Part III: Plots
More informationAn Introduction to MATLAB II
Lab of COMP 319 An Introduction to MATLAB II Lab tutor : Gene Yu Zhao Mailbox: csyuzhao@comp.polyu.edu.hk or genexinvivian@gmail.com Lab 2: 16th Sep, 2013 1 Outline of Lab 2 Review of Lab 1 Matrix in Matlab
More informationIntroduction to MatLab. Introduction to MatLab K. Craig 1
Introduction to MatLab Introduction to MatLab K. Craig 1 MatLab Introduction MatLab and the MatLab Environment Numerical Calculations Basic Plotting and Graphics Matrix Computations and Solving Equations
More informationHow 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 information2.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 informationPART 1 PROGRAMMING WITH MATHLAB
PART 1 PROGRAMMING WITH MATHLAB Presenter: Dr. Zalilah Sharer 2018 School of Chemical and Energy Engineering Universiti Teknologi Malaysia 23 September 2018 Programming with MATHLAB MATLAB Environment
More informationIntroduction to Matlab
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 informationInteractive Computing with Matlab. Gerald W. Recktenwald Department of Mechanical Engineering Portland State University
Interactive Computing with Matlab Gerald W. Recktenwald Department of Mechanical Engineering Portland State University gerry@me.pdx.edu Starting Matlab Double click on the Matlab icon, or on unix systems
More informationAMS 27L LAB #2 Winter 2009
AMS 27L LAB #2 Winter 2009 Plots and Matrix Algebra in MATLAB Objectives: 1. To practice basic display methods 2. To learn how to program loops 3. To learn how to write m-files 1 Vectors Matlab handles
More informationQUICK 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 informationMatlab 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 informationProgramming in Mathematics. Mili I. Shah
Programming in Mathematics Mili I. Shah Starting Matlab Go to http://www.loyola.edu/moresoftware/ and login with your Loyola name and password... Matlab has eight main windows: Command Window Figure Window
More informationIntroduction to Matlab. By: Dr. Maher O. EL-Ghossain
Introduction to Matlab By: Dr. Maher O. EL-Ghossain Outline: q What is Matlab? Matlab Screen Variables, array, matrix, indexing Operators (Arithmetic, relational, logical ) Display Facilities Flow Control
More informationIntroduction to 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 informationEE 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 informationCreates a 1 X 1 matrix (scalar) with a value of 1 in the column 1, row 1 position and prints the matrix aaa in the command window.
EE 350L: Signals and Transforms Lab Spring 2007 Lab #1 - Introduction to MATLAB Lab Handout Matlab Software: Matlab will be the analytical tool used in the signals lab. The laboratory has network licenses
More informationIntroduction 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 informationEric 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 informationECE 3793 Matlab Project 1
ECE 3793 Matlab Project 1 Spring 2017 Dr. Havlicek DUE: 02/04/2017, 11:59 PM Introduction: You will need to use Matlab to complete this assignment. So the first thing you need to do is figure out how you
More informationLAB 1: Introduction to MATLAB Summer 2011
University of Illinois at Urbana-Champaign Department of Electrical and Computer Engineering ECE 311: Digital Signal Processing Lab Chandra Radhakrishnan Peter Kairouz LAB 1: Introduction to MATLAB Summer
More informationUNIVERSITI 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 informationLecture 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 informationConstraint-based Metabolic Reconstructions & Analysis H. Scott Hinton. Matlab Tutorial. Lesson: Matlab Tutorial
1 Matlab Tutorial 2 Lecture Learning Objectives Each student should be able to: Describe the Matlab desktop Explain the basic use of Matlab variables Explain the basic use of Matlab scripts Explain the
More informationChapter 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 informationMATLAB 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 informationAN 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 informationLAB 1 General MATLAB Information 1
LAB 1 General MATLAB Information 1 General: To enter a matrix: > type the entries between square brackets, [...] > enter it by rows with elements separated by a space or comma > rows are terminated by
More informationEE3TP4: Signals and Systems Lab 1: Introduction to Matlab Tim Davidson Ext Objective. Report. Introduction to Matlab
EE3TP4: Signals and Systems Lab 1: Introduction to Matlab Tim Davidson Ext. 27352 davidson@mcmaster.ca Objective To help you familiarize yourselves with Matlab as a computation and visualization tool in
More informationEGR 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 informationSummer 2009 REU: Introduction to Matlab
Summer 2009 REU: Introduction to Matlab Moysey Brio & Paul Dostert June 29, 2009 1 / 19 Using Matlab for the First Time Click on Matlab icon (Windows) or type >> matlab & in the terminal in Linux. Many
More informationLaboratory 1 Octave Tutorial
Signals, Spectra and Signal Processing Laboratory 1 Octave Tutorial 1.1 Introduction The purpose of this lab 1 is to become familiar with the GNU Octave 2 software environment. 1.2 Octave Review All laboratory
More informationGrace 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 informationPhysics 326G Winter Class 2. In this class you will learn how to define and work with arrays or vectors.
Physics 326G Winter 2008 Class 2 In this class you will learn how to define and work with arrays or vectors. Matlab is designed to work with arrays. An array is a list of numbers (or other things) arranged
More informationMATLAB 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 informationGetting Started with MATLAB
Getting Started with MATLAB Math 4600 Lab: Gregory Handy http://www.math.utah.edu/ borisyuk/4600/ Logging in for the first time: This is what you do to start working on the computer. If your machine seems
More informationIntroduction to Matlab
What is Matlab? Introduction to 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 informationExperiment 1: Introduction to MATLAB I. Introduction. 1.1 Objectives and Expectations: 1.2 What is MATLAB?
Experiment 1: Introduction to MATLAB I Introduction MATLAB, which stands for Matrix Laboratory, is a very powerful program for performing numerical and symbolic calculations, and is widely used in science
More informationMatlab Tutorial. The value assigned to a variable can be checked by simply typing in the variable name:
1 Matlab Tutorial 1- What is Matlab? Matlab is a powerful tool for almost any kind of mathematical application. It enables one to develop programs with a high degree of functionality. The user can write
More informationWhat is MATLAB? What is MATLAB? Programming Environment MATLAB PROGRAMMING. Stands for MATrix LABoratory. A programming environment
What is MATLAB? MATLAB PROGRAMMING Stands for MATrix LABoratory A software built around vectors and matrices A great tool for numerical computation of mathematical problems, such as Calculus Has powerful
More informationTo start using Matlab, you only need be concerned with the command window for now.
Getting Started Current folder window Atop the current folder window, you can see the address field which tells you where you are currently located. In programming, think of it as your current directory,
More informationMAT 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 informationPowerPoints 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 informationChapter 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 informationINTRODUCTION TO MATLAB PLOTTING WITH MATLAB
1 INTRODUCTION TO MATLAB PLOTTING WITH MATLAB Plotting with MATLAB x-y plot Plotting with MATLAB MATLAB contains many powerful functions for easily creating plots of several different types. Command plot(x,y)
More informationGeorge Mason University Signals and Systems I Spring 2016
George Mason University Signals and Systems I Spring 2016 Laboratory Project #1 Assigned: January 25, 2016 Due Date: Laboratory Section on Week of February 15, 2016 Description: The purpose of this laboratory
More information12 whereas if I terminate the expression with a semicolon, the printed output is suppressed.
Example 4 Printing and Plotting Matlab provides numerous print and plot options. This example illustrates the basics and provides enough detail that you can use it for typical classroom work and assignments.
More informationGetting Started. Chapter 1. How to Get Matlab. 1.1 Before We Begin Matlab to Accompany Lay s Linear Algebra Text
Chapter 1 Getting Started How to Get Matlab Matlab physically resides on each of the computers in the Olin Hall labs. See your instructor if you need an account on these machines. If you are going to go
More informationIntroduction to MATLAB LAB 1
Introduction to MATLAB LAB 1 1 Basics of MATLAB MATrix LABoratory A super-powerful graphing calculator Matrix based numeric computation Embedded Functions Also a programming language User defined functions
More informationMATLAB GUIDE UMD PHYS401 SPRING 2012
MATLAB GUIDE UMD PHYS40 SPRING 202 We will be using Matlab (or, equivalently, the free clone GNU/Octave) this semester to perform calculations involving matrices and vectors. This guide gives a brief introduction
More informationLecturer: 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 informationMATH (CRN 13695) Lab 1: Basics for Linear Algebra and Matlab
MATH 495.3 (CRN 13695) Lab 1: Basics for Linear Algebra and Matlab Below is a screen similar to what you should see when you open Matlab. The command window is the large box to the right containing the
More informationIntroduction to Matlab
Introduction to Matlab Kristian Sandberg Department of Applied Mathematics University of Colorado Goal The goal with this worksheet is to give a brief introduction to the mathematical software Matlab.
More informationSome 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 informationIntroduction to MATLAB
Introduction to MATLAB 1 Introduction to MATLAB A Tutorial for the Course Computational Intelligence http://www.igi.tugraz.at/lehre/ci Stefan Häusler Institute for Theoretical Computer Science Inffeldgasse
More informationELEC4042 Signal Processing 2 MATLAB Review (prepared by A/Prof Ambikairajah)
Introduction ELEC4042 Signal Processing 2 MATLAB Review (prepared by A/Prof Ambikairajah) MATLAB is a powerful mathematical language that is used in most engineering companies today. Its strength lies
More informationIntroduction to MATLAB Programming
Introduction to MATLAB Programming Arun A. Balakrishnan Asst. Professor Dept. of AE&I, RSET Overview 1 Overview 2 Introduction 3 Getting Started 4 Basics of Programming Overview 1 Overview 2 Introduction
More informationIntroduction to Matlab
Introduction to Matlab 1 Outline: What is Matlab? Matlab Screen Variables, array, matrix, indexing Operators (Arithmetic, relational, logical ) Display Facilities Flow Control Using of M-File Writing User
More informationMatlab 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 informationEEE161 Applied Electromagnetics Laboratory 1
EEE161 Applied Electromagnetics Laboratory 1 Instructor: Dr. Milica Marković Office: Riverside Hall 3028 Email: milica@csus.edu Web:http://gaia.ecs.csus.edu/ milica This laboratory exercise will introduce
More informationIntroduction 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 informationAppendix A. Introduction to MATLAB. A.1 What Is MATLAB?
Appendix A Introduction to MATLAB A.1 What Is MATLAB? MATLAB is a technical computing environment developed by The Math- Works, Inc. for computation and data visualization. It is both an interactive system
More informationIntroduction to Matlab
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 informationStarting Matlab. MATLAB Laboratory 09/09/10 Lecture. Command Window. Drives/Directories. Go to.
Starting Matlab Go to MATLAB Laboratory 09/09/10 Lecture Lisa A. Oberbroeckling Loyola University Maryland loberbroeckling@loyola.edu http://ctx.loyola.edu and login with your Loyola name and password...
More informationA General Introduction to Matlab
Master Degree Course in ELECTRONICS ENGINEERING http://www.dii.unimore.it/~lbiagiotti/systemscontroltheory.html A General Introduction to Matlab e-mail: luigi.biagiotti@unimore.it http://www.dii.unimore.it/~lbiagiotti
More informationINTRODUCTION 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 informationUniversity 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 informationMatlab 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 informationAn Introduction to Numerical Methods
An Introduction to Numerical Methods Using MATLAB Khyruddin Akbar Ansari, Ph.D., P.E. Bonni Dichone, Ph.D. SDC P U B L I C AT I O N S Better Textbooks. Lower Prices. www.sdcpublications.com Powered by
More informationIntroduction to Matlab
Introduction to Matlab 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 informationThe value of f(t) at t = 0 is the first element of the vector and is obtained by
MATLAB Tutorial This tutorial will give an overview of MATLAB commands and functions that you will need in ECE 366. 1. Getting Started: Your first job is to make a directory to save your work in. Unix
More informationDSP Laboratory (EELE 4110) Lab#1 Introduction to Matlab
Islamic University of Gaza Faculty of Engineering Electrical Engineering Department 2012 DSP Laboratory (EELE 4110) Lab#1 Introduction to Matlab Goals for this Lab Assignment: In this lab we would have
More informationIntroduction 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 information1-- Pre-Lab The Pre-Lab this first week is short and straightforward. Make sure that you read through the information below prior to coming to lab.
EELE 477 Lab 1: Introduction to MATLAB Pre-Lab and Warm-Up: You should read the Pre-Lab and Warm-up sections of this lab assignment and go over all exercises in the Pre-Lab section before attending your
More informationMcTutorial: A MATLAB Tutorial
McGill University School of Computer Science Sable Research Group McTutorial: A MATLAB Tutorial Lei Lopez Last updated: August 2014 w w w. s a b l e. m c g i l l. c a Contents 1 MATLAB BASICS 3 1.1 MATLAB
More informationHow to Use MATLAB. What is MATLAB. Getting Started. Online Help. General Purpose Commands
How to Use MATLAB What is MATLAB MATLAB is an interactive package for numerical analysis, matrix computation, control system design and linear system analysis and design. On the server bass, MATLAB version
More informationMATLAB Basics EE107: COMMUNICATION SYSTEMS HUSSAIN ELKOTBY
MATLAB Basics EE107: COMMUNICATION SYSTEMS HUSSAIN ELKOTBY What is MATLAB? MATLAB (MATrix LABoratory) developed by The Mathworks, Inc. (http://www.mathworks.com) Key Features: High-level language for numerical
More informationMATLAB Tutorial. Mohammad Motamed 1. August 28, generates a 3 3 matrix.
MATLAB Tutorial 1 1 Department of Mathematics and Statistics, The University of New Mexico, Albuquerque, NM 87131 August 28, 2016 Contents: 1. Scalars, Vectors, Matrices... 1 2. Built-in variables, functions,
More informationMATLAB Introduction to MATLAB Programming
MATLAB Introduction to MATLAB Programming MATLAB Scripts So far we have typed all the commands in the Command Window which were executed when we hit Enter. Although every MATLAB command can be executed
More informationIntroduction 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 informationMATLAB Lesson I. Chiara Lelli. October 2, Politecnico di Milano
MATLAB Lesson I Chiara Lelli Politecnico di Milano October 2, 2012 MATLAB MATLAB (MATrix LABoratory) is an interactive software system for: scientific computing statistical analysis vector and matrix computations
More informationPC-MATLAB PRIMER. This is intended as a guided tour through PCMATLAB. Type as you go and watch what happens.
PC-MATLAB PRIMER This is intended as a guided tour through PCMATLAB. Type as you go and watch what happens. >> 2*3 ans = 6 PCMATLAB uses several lines for the answer, but I ve edited this to save space.
More informationMATLAB 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 informationIntroduction 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 information1. Register an account on: using your Oxford address
1P10a MATLAB 1.1 Introduction MATLAB stands for Matrix Laboratories. It is a tool that provides a graphical interface for numerical and symbolic computation along with a number of data analysis, simulation
More informationINTRODUCTION 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 informationGeneral MATLAB Information 1
Introduction to MATLAB General MATLAB Information 1 Once you initiate the MATLAB software, you will see the MATLAB logo appear and then the MATLAB prompt >>. The prompt >> indicates that MATLAB is awaiting
More informationIntroduction 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 informationIntroduction to MATLAB Practical 1
Introduction to MATLAB Practical 1 Daniel Carrera November 2016 1 Introduction I believe that the best way to learn Matlab is hands on, and I tried to design this practical that way. I assume no prior
More informationLab of COMP 406. MATLAB: Quick Start. Lab tutor : Gene Yu Zhao Mailbox: or Lab 1: 11th Sep, 2013
Lab of COMP 406 MATLAB: Quick Start Lab tutor : Gene Yu Zhao Mailbox: csyuzhao@comp.polyu.edu.hk or genexinvivian@gmail.com Lab 1: 11th Sep, 2013 1 Where is Matlab? Find the Matlab under the folder 1.
More informationIntroduction to MATLAB
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 informationIntroduction to Matlab to Accompany Linear Algebra. Douglas Hundley Department of Mathematics and Statistics Whitman College
Introduction to Matlab to Accompany Linear Algebra Douglas Hundley Department of Mathematics and Statistics Whitman College August 27, 2018 2 Contents 1 Getting Started 5 1.1 Before We Begin........................................
More informationStarting MATLAB To logon onto a Temple workstation at the Tech Center, follow the directions below.
What is MATLAB? MATLAB (short for MATrix LABoratory) is a language for technical computing, developed by The Mathworks, Inc. (A matrix is a rectangular array or table of usually numerical values.) MATLAB
More informationWhat is MATLAB? It is a high-level programming language. for numerical computations for symbolic computations for scientific visualizations
What is MATLAB? It stands for MATrix LABoratory It is developed by The Mathworks, Inc (http://www.mathworks.com) It is an interactive, integrated, environment for numerical computations for symbolic computations
More informationMATLAB Tutorial Matrices & Vectors MATRICES AND VECTORS
MATRICES AND VECTORS A matrix (m x n) with m rows and n columns, a column vector (m x 1) with m rows and 1 column, and a row vector (1 x m) with 1 row and m columns all can be used in MATLAB. Matrices
More information2D LINE PLOTS... 1 The plot() Command... 1 Labeling and Annotating Figures... 5 The subplot() Command... 7 The polarplot() Command...
Contents 2D LINE PLOTS... 1 The plot() Command... 1 Labeling and Annotating Figures... 5 The subplot() Command... 7 The polarplot() Command... 9 2D LINE PLOTS One of the benefits of programming in MATLAB
More informationMAT 275 Laboratory 1 Introduction to MATLAB
MATLAB sessions: Laboratory 1 1 MAT 275 Laboratory 1 Introduction to MATLAB MATLAB is a computer software commonly used in both education and industry to solve a wide range of problems. This Laboratory
More information