CDA6530: Performance Models of Computers and Networks Chapter 4: Using Matlab for Performance Analysis and Simulation TexPoint fonts used in EMF. Read.

Slides:



Advertisements
Similar presentations
MATLAB – A Computational Methods By Rohit Khokher Department of Computer Science, Sharda University, Greater Noida, India MATLAB – A Computational Methods.
Advertisements

StatLab Workshop Yale University Maximiliano Appendino, Economics October 18 th, 2013.
Lecture 5.
Introduction to Matlab
1 EMT 101 – Engineering Programming Dr. Farzad Ismail School of Aerospace Engineering Universiti Sains Malaysia Nibong Tebal Pulau Pinang Week 10.
Matlab Graphics S. Awad, Ph.D. M. Corless, M.S.E.E. E.C.E. Department University of Michigan-Dearborn Introduction to Matlab: 2D Graphics.
Introduction to Matlab Workshop Matthew Johnson, Economics October 17, /13/20151.
Introduction to MATLAB for Biomedical Engineering BME 1008 Introduction to Biomedical Engineering FIU, Spring 2015 Lesson 2: Element-wise vs. matrix operations.
MATLAB - Basics Centro de Informática Universidade Federal de Pernambuco Aprendizagem de Máquina – IN1102 Arley Ristar –
Introduction to MATLAB
MATLAB ME1107 Y Yan Reference: MATLAB for Engineers by Holly Moore (Pearson Prentice Hall)
Introduction to MATLAB ES 156 Signals and Systems 2008 Harvard SEAS.
MATLAB TUTORIAL Dmitry Drutskoy Some material borrowed from the departmental MATLAB info session by Philippe Rigollet Kevin Wayne.
Dr. Jie Zou PHY Welcome to PHY 3320 Computational Methods in Physics and Engineering.
Introduction to MATLAB ES 156 Signals and Systems 2007 Harvard SEAS Prepared by Jiajun Gu.
EGR 105 Foundations of Engineering I Session 3 Excel – Basics through Graphing Fall 2008.
Introduction to Matlab Jianguo Wang CSSCR September 2009.
Chapter 10 Review: Matrix Algebra
Chapter 5 Review: Plotting Introduction to MATLAB 7 Engineering 161.
MATLAB Lecture One Monday 4 July Matlab Melvyn Sim Department of Decision Sciences NUS Business School
MATLAB INTRO CONTROL LAB1  The Environment  The command prompt Getting Help : e.g help sin, lookfor cos Variables Vectors, Matrices, and Linear Algebra.
Martin Ellison University of Warwick and CEPR Bank of England, December 2005 Introduction to MATLAB.
Nonparametric Econometrics1 Intro to Matlab for Data Analysis and Statistical Modeling.
1 M ATLAB Short Course. History of Calculator 2 3 Introduction to Matlab Matlab is short for Matrix Laboratory Matlab is also a programming language.
Introduction to MATLAB adapted from Dr. Rolf Lakaemper.
Introduction to MATLAB January 18, 2008 Steve Gu Reference: Eta Kappa Nu, UCLA Iota Gamma Chapter, Introduction to MATLAB,
Introduction to Matlab 1. Outline: What is Matlab? Matlab Screen Variables, array, matrix, indexing Operators Plotting Flow Control Using of M-File Writing.
Data, graphics, and programming in R 28.1, 30.1, Daily:10:00-12:45 & 13:45-16:30 EXCEPT WED 4 th 9:00-11:45 & 12:45-15:30 Teacher: Anna Kuparinen.
ELG 3120 Signal and System Analysis 1 Introduction to MATLAB TAs Wei Zhang Ozgur Ekici (Section A)(Section B) ELG 3120 Lab Tutorial 1.
Introduction to MATLAB Computational Probability and Statistics CIS 2033 Section 003 Djordje Gligorijevic, Temple University, Fall 2015.
Introduction to MATLAB CBE 502 Mathematical Methods of Engineering Analysis.
Eng Ship Structures 1 Introduction to Matlab.
INTRODUCTION TO MATLAB LAB# 01
Matlab Basics Tutorial. Vectors Let's start off by creating something simple, like a vector. Enter each element of the vector (separated by a space) between.
CMPS 1371 Introduction to Computing for Engineers MATRICES.
Matlab Programming for Engineers Dr. Bashir NOURI Introduction to Matlab Matlab Basics Branching Statements Loops User Defined Functions Additional Data.
Recap Script M-file Editor/Debugger Window Cell Mode Chapter 3 “Built in MATLAB Function” Using Built-in Functions Using the HELP Feature Window HELP.
Advanced Topics- Functions Introduction to MATLAB 7 Engineering 161.
Recap Sum and Product Functions Matrix Size Function Variance and Standard Deviation Random Numbers Complex Numbers.
Scientific Computing Introduction to Matlab Programming.
Matlab 14.html Cost: $100 Available in labs on Windows and Unix machines.
Introduction to MATLAB adapted from Dr. Rolf Lakaemper.
OUTLINE Overview Numbers, variables and similar in Matlab
Matlab Screen  Command Window  type commands  Current Directory  View folders and m-files  Workspace  View program variables  Double click on a.
Introduction to Matlab By E. Noura Semary. Contents MATLAB Environment  Command window, Workspace, Path window, Editor window,and Figure window) Basic.
MATLAB Lecture Two Tuesday 5 July Chapter 3.
Introduction to Matlab Electromagnetic Theory LAB by Engr. Mian Shahzad Iqbal.
Introduction to MATLAB 1.Basic functions 2.Vectors, matrices, and arithmetic 3.Flow Constructs (Loops, If, etc) 4.Create M-files 5.Plotting.
1 Lecture 3 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept.
1 Faculty Name Prof. A. A. Saati. 2 MATLAB Fundamentals 3 1.Reading home works ( Applied Numerical Methods )  CHAPTER 2: MATLAB Fundamentals (p.24)
Intro to Matlab Rogelio Long September 3, How to access MyDesktop Log in with your utep id and password.
Matlab Tutorial Iman Moazzen First Session – September 11, 2013.
An Introduction to Programming in Matlab Emily Blumenthal
MATLAB (Matrix Algebra laboratory), distributed by The MathWorks, is a technical computing environment for high performance numeric computation and.
NoViC, Dept. of Mechanical Eng Acoustics Lab., NoViC 1. Download Matlab 2.
Outline What is MATLAB MATLAB desktop Variables, Vectors and Matrices Matrix operations Array operations Built-in functions: Scalar, Vector, Matrix Data.
Tutorial on Matlab Basics
Introduction to MATLAB
Signals in Matlab Matlab as a name stands for Matrix Laboratory.
Introduction to Mat lab
TexPoint fonts used in EMF.
INTRODUCTION TO BASIC MATLAB
MATLAB DENC 2533 ECADD LAB 9.
Introduction to Matlab
Matlab Workshop 9/22/2018.
StatLab Matlab Workshop
StatLab Workshop: Intro to Matlab for Data Analysis and Statistical Modeling 11/29/2018.
Demo of Basic Matlab Features
How to Use MATLAB A Brief Introduction.
Matlab Basics Tutorial
Presentation transcript:

CDA6530: Performance Models of Computers and Networks Chapter 4: Using Matlab for Performance Analysis and Simulation TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: AAAAAAAAAAAA

2 Objective  Learn a useful tool for mathematical analysis and simulation  Interpreted language, easy to learn  Use it to facilitate our simulation projects  A good tool to plot simulation/experiment results figures for academic papers  More powerful than excel  Could directly create.eps for Latex

3 Introduction  MatLab : Matrix Laboratory  Numerical Computations with matrices  Every number can be represented as matrix  Why Matlab?  User Friendly (GUI)  Easy to work with  Powerful tools for complex mathematics  Matlab has extensive demo and tutorials to learn by yourself  Use help command

Matlab Software Access  all UCF in-campus computers have student-version Matlab installed  If you have no access to Matlab, you can use Octave, an open-source free software   The programming should be almost identical 4

5 Matrices in Matlab  To enter a matrix >> A = [2 5 3; 6 4 1] >> B = [1:1.5:6; ] >> for i=1:4 for j=1:3 C(i,j)=i*j; end >> D =[]; D=[D;5]; D=[D;6;7] >> E = zeros(4, 5)

6 Basic Mathematical Operations Remember that every variable can be a matrix! Addition: >> C = A + B Subtraction: >> D = A – B Multiplication: >> E = A * B (Matrix multiplication) >> E = A.* B (Element wise multiplication, A and B same size) Division: Left Division and Right Division >> F = A. / B (Element wise division) >> F = A / B = A*inv(B) (A * inverse of B) >> F = A. \ B (Element wise division) >> F = A \ B=inv(A)*B (inverse of A * B)

7 Matrix with ZEROS: >> A = zeros(m, n) Matrix with ONES: >> B = ones(m, n) IDENTITY Matrix: >> I = eye(m, n) m  Rows n  Columns zeros, ones, eye  Matlab functions Generating basic matrices

8 Obtain Information  Size(A): return [m n]  Length(A): length of a vector  Length(A) = max(size(A))  B = A(2:4,3:5)  B is the subset of A from row 2 to row 4, column 3 to column 5  A(:, 2)=[]  Delete second column

9 Basic Matrix Functions  Inv(A): inverse of A  Rank(A): rank of matrix A  A’: transpose of A  Det(A): determinant  V= eig(A): eigenvalue vector of A  [V,D] = eig(A) produces matrices of eigenvalues (D) and eigenvectors (V) of matrix A, so that A*V = V*D

10 Random Number Generators  Rand(m,n): matrix with each entry ~ U(0,1)  You can use this for the programming project 1  Randn(m,n): standard normal distribution  You cannot use this in programming project 1  You must use the polar method I introduced!

11 Basic 2-D Figure Plot  Plot(X, Y):  Plots vector Y versus vector X  Hold: next plot action on the same figure  Title(‘title text here’)  Xlabel(‘…’), ylabel(‘…’)  Axis([XMIN XMAX YMIN YMAX])  Legend(‘…’)  Grid  Example demo

12 Elementary Math Function  Abs(), sign()  Sign(A) = A./abs(A)  Sin(), cos(), asin(), acos()  Exp(), log(), log10()  Ceil(), floor()  Sqrt()  Real(), imag()

13 Elementary Math Function  Vector operation:  Max(), min(): max/min element of a vector  Mean(), median()  Std(), var(): standard deviation and variance  Sum(), prod(): sum/product of elements  Sort(): sort in ascending order

14 Save/Load Data  Save fname  Save all workspace data into fname.mat  Save fname x y z  Save(fname): when fname is a variable  Load fname  Load fname x y  No error in data  You can run simulation intermittently  Save/load data between runs

15 Input/Output for Text Files  Input data file for further analysis in Matlab  Run simulation using C  matlab is slow in doing many loops  Use Matlab for post-data processing  Matrix calculation, utilize Matlab math functions  Simply use Matlab for figure ploting  Excel has constraint on data vector length (<300?)  Functions:  [A,B…]= Textread(fname, format)  Read formated data  Use fprintf(), fscanf() similar to C  Note that variables here can be vectors/matrices  Show examples here of writing data to text file

16 Advanced Graph  Subplot(m, n, p)  breaks the Figure window into an m-by-n matrix of small axes, selects the p-th axes for the current plot, and returns the axis handle.  Semilogx(), semilogy(), loglog()

17 3-D plot  x=[0:10]; y=[0:10]; z=x ’ *y;  mesh(x,y,z); figure; surf(x,y,z);

18 M-file  Script or function  Scripts are m-files containing MATLAB statements  Functions are like any other m-file, but they accept arguments  It is always recommended to name function file the same as the function name function A = changeSign(B) % change sign for each element [m,n] = size(B); A = zeros(m,n); for i=1:m for j=1:n A(i,j)= -B(i,j); end return

19 Online Tutorials  Matlab itself contains many tutorials  Other online tutorials:   s/matlab_tutorial.pdf s/matlab_tutorial.pdf  Google search “matlab tutorial ppt” to find a lot more

20 Example on Using Matlab for Markov Chain Steady State Calculation

21  Discrete-time Markov Chain transition matrix:  ¼ P = ¼, ¼ [1 1 1… 1] T = 1  ¼ (P – I) = 0, But we cannot use it directly  Replace first column in (P-I) with [1 1..1] T to be A, then we can solve the linear equation set by ¼ = [1 0 0 … 0] A -1  Another way: P*P*P*P……

22 Tutorial on Matlab Simulink

23  Graphical programming language  Drag and draw line to program  Configure each object for parameters  Powerful modeling tool  Differential Equations  Physiological systems  Control systems  Transfer functions  M-file can call a simulink model  “ sim fname ”  Use current workspace variables  Simulation results can be saved to workspace variables  Thus can be process after simulink

24 Example: Internet Worm Propagation  N: vulnerable population  : worm host average scan rate   : scanning IP space size

Example 2: RC Circuit 25 Transfer function:

Save result to workspace variables  the save format is "structure with time".  Suppose the workspace variable is X_t.  Then:  X_t.time saves the simulation step times (vector)  X_t.signals.values saves the simulation results (vector).  plot(X_t.time, X_t.signals.values);  Variable step simulation or fixed step simulation:  "to workspace" use "-1" for sample time (inherited)  Then X_t.time has variable size  "to workspace" use "1" for sample time  Then each time tick has one result value 26