BSM510 Numerical Analysis

Size: px
Start display at page:

Download "BSM510 Numerical Analysis"

Transcription

1 BSM510 Numerical Analysis Introduction and Matlab Fundamentals Manar Mohaisen Department of EEC Engineering

2 Lecture Content Introduction to MATLAB 2

3 Introduction to MATLAB MATLAB 3

4 Scalars >> x = 5; x 5 >> y = sin(pi/4); x >> z = power(2, 5); % 2 to power 5 z 32 >> data = 5/2 + 5; data 7.5 >> d = 5 + j3; d 5 + sqrt(-1)*3 d = d / 2; d j1.5 >> scale = sqrt(sin(0.5*pi*real(d))); scale sqrt(sin(3/4*pi)) = i

5 Vectors >> x = [1 3 5]; x is a row vector of size 13 >> y = x.^2; % y[i] = x[i]*x[i] y [1 9 25] >> p = sum(y); p is the total power of x >> vec = x. ; vec is a column vector = [1 3 5] T % transpose operator >> q = [5, 3, -1.1]; % equivalent to [ ] q is a row vector of size 13 >> v = [-9; 4; 16]; v is a column vector of size 31 >> sr = sqrt(v); sr [3i; 2; 4], with i = sqrt(-1) 5

6 Vectors contd. >> re = [ ]. ; >> im = [ ]. ; >> co = re + sqrt(-1)*im; co [7+i 3+i3 2+i -1] T ; coct = co. ; cot = [7+i 3+i3 2+i -1] cort = co ; cot = [7-i 3-i3 2-i -1] >> mul = re.*im; mul = [7; 9; 2; 0] >> div = 7*im./re; % transpose % conjugate transpose % element-wise multiplication div = [1; 7; 3.5; 0] >> une = ones(1, 5); zero = zeros(1, 4); une [ ]; zero = [ ]; 6

7 Vectors contd. >> index = 1:2:9; index [ ] >> range = 5:-0.5:3; range [ ] >> a = [ ]; b = [ ]; >> y = a*b. ; y 28.5 >> z = a*b; % vector multiplication Wrong: inner matrix dimensions must agree >> x = a(1, 1:2); w = [a(1) a(3) a(2)]; z=a(4:-1:1); x [1-1]; w [1 5-1]; z = [ ]; >> v1 = max(a); v2 = min(a); v3 = var(a); >> v4 = mod(b, 2); v4 [ ] 7

8 Vectors contd. >> x = [ ]; >> Y = diag(x); >> q = prod(x); q = -15 % product of the elements of x >> y = find(x >= 2); % indices of elements >= 2 y [2 3] Y >> num = prod(size(y)); % the number of elements >= 2 num >> y = [ ]; >> m = [x y]; z = [x; y]; m [ ] z

9 Vectors example Plot the following function using commands in the command window f() x 1 e 2 x2/2 >> x = [-5:0.1:5]; % range of ind. variable >> f = 1/sqrt(2*pi) * exp(-x.^2./ 2); % dependent variable >> plot(x, f, linewidth, 1.5) % 2d plot >> xlabel( x ) >> ylabel( f(x) ) >> grid on % add the grid to the figure f(x) x 9

10 Vectors example Plot the following function in the range [-5, 5] with increment 0.05 fx () sin(2 x)cos( x) x2 1 >> x = [-5:0.05:5]; % range of ind. variable >> f = sin(2*pi*x).*cos(pi*x); % divide expression into 1 >> f = f./(x.^2 + 1); % and 2 >> plot(x, f, linewidth, 1.1) % 2d plot >> axis([ ]; %axis([xmin xmax ymin ymax]) >> xlabel( x ) >> ylabel( f(x) ) >> grid on % add the grid to the figure 0.5 f(x) x 10

11 Vectors creating functions (m files) The function should have the following form Programmed in the edit window, then it is called in the command window or in other function or m file function [list of outputs] = functionname(list of inputs) % function s body % Example 1 function [val] = NormalF(x, a, b) % returns the value of the pdf of gaussian RV at x % a is the variance and b is the mean % Val = 1/sqrt(2*pi*a) * exp(-(x-b)^2 / (2*a) ) Example 2 function [vecp] = vecpower(v) % returns the total power of the vector v v = v(:); % v becomes column vector vecp = v *v; % works for complex vectors as well 11

12 Vectors example function [va vn] = acceleration(m, cd) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % inputs: m (kg) % cd (kg/m) % outputs: va analytical results % vn numerical results %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% g = 9.81; % acceleration due to gravity t = 0:0.5:12; % time range va = sqrt(g*m/cd).*tanh(sqrt(g*cd/m).*t); % analytical velocity vn = zeros(1, length(t)); % initiate numerical v to zero for ii = 2 : 1 : length(t) vn(ii) = vn(ii-1) + (g - cd/m*vn(ii-1)^2) * (t(ii)-t(ii-1)); end plot(t, va, '-o') % plot the analytical results hold % hold the plot to add other curve plot(t, vn, 'r') % plot the numerical results xlabel('time (s)'); % set the x label ylabel('v (m/s)'); % set the y label grid on % show the grid v (m/s) analytical numerical time (s) 12

13 Vectors random values % Gaussian numbers >> x = randn(1, 4); % Gaussian random values w. mean=0, var=1 >> y = randn(1, 4)+2; % Gaussian random values w. mean=2, var=1 >> z = 2*randn(1, 4)-2; % Gaussian random values w. mean=-2, var=4 >> w = (randn(1, 4) >= 0); % generates binary numbers with equal prob % equal probability integers >> x = randint(1, 4); % binary values >> y = randint(1, 4, [-2 2]); % random int in [-2,2] ( ) % any real value with any probability >> a = randsrc(1, 4, [1 3]); % random numbers 1 or 3 (same prob) >> b = randsrc(1, 4, [1 3; ]);% prob(1) = 0.4, prob(3) = 0.6 % real random numbers (uniform distribution) >> g = rand(1, 4); % real numbers in [0, 1] with equal prob >> h = rand(1, 4) 0.5; % real numbers in [-0.5, 0.5] with equal prob % try to check the help on those functions using the help command >> help rand 13

14 Matrices A vector is a special case of matrices that has either dimension = 1 All what we introduces about vectors still applied to matrices >> x = [2 4; 5 1] % 2x2 matrix, the ; separates rows >> y = [5 1 7; 3 1 0]; % 2x3 matrix >> z = randn(5); % 5x5 matrix with N(0,1) entries >> w = diag(z); % 5x1 vector (diagonal elements of z) >> a = transpose(x); >> u = inv(x); >> detx = det(x); >> tracex = trace(x); >> vec = x(:, 1); >> vec1 = x(2, :); % same as x or x. for real % inverse of x % determinant % trace of x % vec is the first column of x % vec1 is the second row of x >> pary = y(:, 1:2); % pary = [5 1; 3 1] >> prodm = x*y; % matrix multiplication 14

15 Matrices contd. >> x = [2 4; 5 1] % 2x2 matrix >> y = x.^2; % y = [4 16; 25 1] >> z = x^2; >> U = trace(x *x); >> logv = log(x); >> w = sqrtm(x); % z = x*x; % what is this? % element-wise log (natural log) % w*w = x >> m = sqrt(x); % m(i,j) = sqrt(x(i, j) >> [a b] = size(x); % a=# of rows, b=#of columns >> n = prod(size(x)); % # of elements in x >> T = reshape(x, 1, 4); % T = [ ] >> U = x(:, [2 1]); % exchange columns 1 and 2 >> M = x*y; >> V = x.*y; % #of col. in x = #of rows in y % x and y are with same dimensions >> P = sum(sum(x.*x)); % total power of x 15

16 Input-output Input >> x = input( display message ) Example: n = input( enter your weight (kg): ) Output >> disp( message to display ) Example: disp( error, please try again! ) >> fprintf( format, values or variables); Example: fprintf( your weight is %f kg, 125.3); Notes» This functionality is same as printf in c» fprintf can be used for both file/screen display in MATLAB 16

17 If statement Loops if (condition 1) statements elseif (condition 2) statements else statements end for index = start:step:end statements end Example if (x > 0) disp( x is positive) elseif (x < 0) disp( x is negative ) else disp( x = 0 ) end Example y(1) = -5; for ii = 2 : 1 : 100 y(ii) = y(ii-1) + ii^2 end 17

18 Relational operators == equal ~= not equal < less than > larger than <=,>= less/larger than Logical operators ~ not & and or 18

19 Anonymous functions Allows you to create a function without creating an M-file. Format: fhandle of args) expression >> a = 5; >> b = 3; >> f1 a*x^2 + b*y^2 >> f1(2, 3) ans = 47 >> a = 10; % does not affect the result >> f1(2, 3) ans = 47 19

20 Function functions A function that takes a function as an argument Example: M-file function favg = funcafvg(f, a, b, n) % inputs: f is a function to be evaluated % [a,b,n] interval limits and # of points x = linspace(a, b, n); Y = f(x); favg = mean(y); Command window >> f1 5*x^2 + 3*x 2; >> funcavf(f1, 0, 12, 60); 20

21 Lecture Summary We introduced an overview of MATLAB 21

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

MATLAB Tutorial. Mohammad Motamed 1. August 28, generates a 3 3 matrix. MATLAB Tutorial 1 1 Department of Mathematics and Statistics, The University of New Mexico, Albuquerque, NM 87131 August 28, 2016 Contents: 1. Scalars, Vectors, Matrices... 1 2. Built-in variables, functions,

More information

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

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

CDA5530: Performance Models of Computers and Networks. Chapter 8: Using Matlab for Performance Analysis and Simulation

CDA5530: Performance Models of Computers and Networks. Chapter 8: Using Matlab for Performance Analysis and Simulation CDA5530: Performance Models of Computers and Networks Chapter 8: Using Matlab for Performance Analysis and Simulation Objective Learn a useful tool for mathematical analysis and simulation Interpreted

More information

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

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

More information

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

Some elements for Matlab programming

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

More information

CDA6530: Performance Models of Computers and Networks. Chapter 4: Using Matlab for Performance Analysis and Simulation

CDA6530: Performance Models of Computers and Networks. Chapter 4: Using Matlab for Performance Analysis and Simulation CDA6530: Performance Models of Computers and Networks Chapter 4: Using Matlab for Performance Analysis and Simulation Objective Learn a useful tool for mathematical analysis and simulation Interpreted

More information

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

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

More information

Getting Started with Matlab

Getting Started with Matlab Chapter Getting Started with Matlab The computational examples and exercises in this book have been computed using Matlab, which is an interactive system designed specifically for scientific computation

More information

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

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

More information

Programming in Mathematics. Mili I. Shah

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

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

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

More information

CDA6530: Performance Models of Computers and Networks. Chapter 4: Using Matlab for Performance Analysis and Simulation

CDA6530: Performance Models of Computers and Networks. Chapter 4: Using Matlab for Performance Analysis and Simulation CDA6530: Performance Models of Computers and Networks Chapter 4: Using Matlab for Performance Analysis and Simulation Objective Learn a useful tool for mathematical analysis and simulation Interpreted

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

Matlab Tutorial. Get familiar with MATLAB by using tutorials and demos found in MATLAB. You can click Start MATLAB Demos to start the help screen.

Matlab Tutorial. Get familiar with MATLAB by using tutorials and demos found in MATLAB. You can click Start MATLAB Demos to start the help screen. University of Illinois at Urbana-Champaign Department of Electrical and Computer Engineering ECE 298JA Fall 2015 Matlab Tutorial 1 Overview The goal of this tutorial is to help you get familiar with MATLAB

More information

Computational Foundations of Cognitive Science. Inverse. Inverse. Inverse Determinant

Computational Foundations of Cognitive Science. Inverse. Inverse. Inverse Determinant Computational Foundations of Cognitive Science Lecture 14: s and in Matlab; Plotting and Graphics Frank Keller School of Informatics University of Edinburgh keller@inf.ed.ac.uk February 23, 21 1 2 3 Reading:

More information

12 whereas if I terminate the expression with a semicolon, the printed output is suppressed.

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

Control Structures. March 1, Dr. Mihail. (Dr. Mihail) Control March 1, / 28

Control Structures. March 1, Dr. Mihail. (Dr. Mihail) Control March 1, / 28 Control Structures Dr. Mihail March 1, 2015 (Dr. Mihail) Control March 1, 2015 1 / 28 Overview So far in this course, MATLAB programs consisted of a ordered sequence of mathematical operations, functions,

More information

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

Constraint-based Metabolic Reconstructions & Analysis H. Scott Hinton. Matlab Tutorial. Lesson: Matlab Tutorial 1 Matlab Tutorial 2 Lecture Learning Objectives Each student should be able to: Describe the Matlab desktop Explain the basic use of Matlab variables Explain the basic use of Matlab scripts Explain the

More information

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

Introduction to. The Help System. Variable and Memory Management. Matrices Generation. Interactive Calculations. Vectors and Matrices Introduction to Interactive Calculations Matlab is interactive, no need to declare variables >> 2+3*4/2 >> V = 50 >> V + 2 >> V Ans = 52 >> a=5e-3; b=1; a+b Most elementary functions and constants are

More information

Introduction to Matlab. CSE555 Introduction to Pattern Recognition Spring 2011 recitation

Introduction to Matlab. CSE555 Introduction to Pattern Recognition Spring 2011 recitation CSE555 Introduction to Pattern Recognition Spring 2011 recitation Matlab stands for Matrix Laboratory. It was originally designed for solving linear algebra problems using matrices. Matlab is also a programming

More information

Introduction To MATLAB Introduction to Programming GENG 200

Introduction To MATLAB Introduction to Programming GENG 200 Introduction To MATLAB Introduction to Programming GENG 200, Prepared by Ali Abu Odeh 1 Table of Contents M Files 2 4 2 Execution Control 3 Vectors User Defined Functions Expected Chapter Duration: 6 classes.

More information

LabVIEW MathScript Quick Reference

LabVIEW MathScript Quick Reference Telemark University College Department of Electrical Engineering, Information Technology and Cybernetics LabVIEW MathScript Quick Reference Hans-Petter Halvorsen, 2012.06.14 Faculty of Technology, Postboks

More information

MATLAB: The greatest thing ever. Why is MATLAB so great? Nobody s perfect, not even MATLAB. Prof. Dionne Aleman. Excellent matrix/vector handling

MATLAB: The greatest thing ever. Why is MATLAB so great? Nobody s perfect, not even MATLAB. Prof. Dionne Aleman. Excellent matrix/vector handling MATLAB: The greatest thing ever Prof. Dionne Aleman MIE250: Fundamentals of object-oriented programming University of Toronto MIE250: Fundamentals of object-oriented programming (Aleman) MATLAB 1 / 1 Why

More information

AMS 27L LAB #2 Winter 2009

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

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

Introduction to MATLAB Practical 1

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

Lecturer: Keyvan Dehmamy

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

More information

Teaching Manual Math 2131

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

More information

MATLAB 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

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

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

More information

Quick MATLAB Syntax Guide

Quick MATLAB Syntax Guide Quick MATLAB Syntax Guide Some useful things, not everything if-statement Structure: if (a = = = ~=

More information

Evolutionary Algorithms. Workgroup 1

Evolutionary Algorithms. Workgroup 1 The workgroup sessions Evolutionary Algorithms Workgroup Workgroup 1 General The workgroups are given by: Hao Wang - h.wang@liacs.leideuniv.nl - Room 152 Furong Ye - f.ye@liacs.leidenuniv.nl Follow the

More information

Introduction to MATLAB

Introduction to MATLAB 58:110 Computer-Aided Engineering Spring 2005 Introduction to MATLAB Department of Mechanical and industrial engineering January 2005 Topics Introduction Running MATLAB and MATLAB Environment Getting help

More information

LAB 1: Introduction to MATLAB Summer 2011

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

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

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

More information

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

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

A Brief Introduction to MATLAB

A Brief Introduction to MATLAB A Brief Introduction to MATLAB MATLAB (Matrix Laboratory) is an interactive software system for numerical computations and graphics. As the name suggests, MATLAB was first designed for matrix computations:

More information

Introduction to GNU-Octave

Introduction to GNU-Octave Introduction to GNU-Octave Dr. K.R. Chowdhary, Professor & Campus Director, JIETCOE JIET College of Engineering Email: kr.chowdhary@jietjodhpur.ac.in Web-Page: http://www.krchowdhary.com July 11, 2016

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

Computational Finance

Computational Finance Computational Finance Introduction to Matlab Marek Kolman Matlab program/programming language for technical computing particularly for numerical issues works on matrix/vector basis usually used for functional

More information

INTRODUCTORY NOTES ON MATLAB

INTRODUCTORY NOTES ON MATLAB INTRODUCTORY NOTES ON MATLAB C Lamas Fernández, S Marelli, B Sudret CHAIR OF RISK, SAFETY AND UNCERTAINTY QUANTIFICATION STEFANO-FRANSCINI-PLATZ 5 CH-8093 ZÜRICH Risk, Safety & Uncertainty Quantification

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. A Tutorial By. Masood Ejaz

MATLAB. A Tutorial By. Masood Ejaz MATLAB A Tutorial By Masood Ejaz Note: This tutorial is a work in progress and written specially for CET 3464 Software Programming in Engineering Technology, a course offered as part of BSECET program

More information

1 Introduction to MATLAB

1 Introduction to MATLAB 1 Introduction to MATLAB 1.1 General considerations The aim of this laboratory is to review some useful MATLAB commands in digital signal processing. MATLAB is one of the fastest and most enjoyable ways

More information

MATLAB/Octave Tutorial

MATLAB/Octave Tutorial University of Illinois at Urbana-Champaign Department of Electrical and Computer Engineering ECE 298JA Fall 2017 MATLAB/Octave Tutorial 1 Overview The goal of this tutorial is to help you get familiar

More information

4.0 Programming with MATLAB

4.0 Programming with MATLAB 4.0 Programming with MATLAB 4.1 M-files The term M-file is obtained from the fact that such files are stored with.m extension. M-files are alternative means of performing computations so as to expand MATLAB

More information

Mathematical Operations with Arrays and Matrices

Mathematical Operations with Arrays and Matrices Mathematical Operations with Arrays and Matrices Array Operators (element-by-element) (important) + Addition A+B adds B and A - Subtraction A-B subtracts B from A.* Element-wise multiplication.^ Element-wise

More information

Introduction to Matlab (CSE)

Introduction to Matlab (CSE) ov Introduction to Matlab ov Scientific Computing in Computer Science Technische Universität München 17-18 October 2013 ov (TUM) 17-18 October 2013 1 / 43 Schedule of the next two days ov Thursday, October

More information

Numerical Methods in Engineering Sciences

Numerical Methods in Engineering Sciences Numerical Methods in Engineering Sciences Lecture 1: Brief introduction to MATLAB Pablo Antolin pablo.antolinsanchez@unipv.it October 29th 2013 How many of you have used MATLAB before? How many of you

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

Homework 1 Description CmpE 362 Spring Instructor : Fatih Alagoz Teaching Assistant : Yekta Said Can Due: 3 March, 23:59, sharp

Homework 1 Description CmpE 362 Spring Instructor : Fatih Alagoz Teaching Assistant : Yekta Said Can Due: 3 March, 23:59, sharp Homework 1 Description CmpE 362 Spring 2016 Instructor : Fatih Alagoz Teaching Assistant : Yekta Said Can Due: 3 March, 23:59, sharp Homework 1 This homework is designed to teach you to think in terms

More information

Introduction to MATLAB for Numerical Analysis and Mathematical Modeling. Selis Önel, PhD

Introduction to MATLAB for Numerical Analysis and Mathematical Modeling. Selis Önel, PhD Introduction to MATLAB for Numerical Analysis and Mathematical Modeling Selis Önel, PhD Advantages over other programs Contains large number of functions that access numerical libraries (LINPACK, EISPACK)

More information

MATLAB INTRO 1. Suppose that we want to define a 3 1 vector x, with elements given as 3,5 and 1. We do this as follows: x = [3; 5; 1]

MATLAB INTRO 1. Suppose that we want to define a 3 1 vector x, with elements given as 3,5 and 1. We do this as follows: x = [3; 5; 1] MATLAB INTRO 1 1 MATLAB Operations Matlab uses the symbols *,/,+,-,and ˆ to denote multiplication, division, addition, subtraction and exponention, respectively. For the case of matrix multiplication,

More information

Introduction to MATLAB Programming

Introduction to MATLAB Programming Introduction to MATLAB Programming Arun A. Balakrishnan Asst. Professor Dept. of AE&I, RSET Overview 1 Overview 2 Introduction 3 Getting Started 4 Basics of Programming Overview 1 Overview 2 Introduction

More information

What is MATLAB? What is MATLAB? Programming Environment MATLAB PROGRAMMING. Stands for MATrix LABoratory. A programming environment

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

MATLAB and Numerical Analysis

MATLAB and Numerical Analysis School of Mechanical Engineering Pusan National University dongwoonkim@pusan.ac.kr Teaching Assistant 김동운 dongwoonkim@pusan.ac.kr 윤종희 jongheeyun@pusan.ac.kr Lab office: 통합기계관 120호 ( 510-3921) 방사선영상연구실홈페이지

More information

Math 7 Elementary Linear Algebra PLOTS and ROTATIONS

Math 7 Elementary Linear Algebra PLOTS and ROTATIONS Spring 2007 PLOTTING LINE SEGMENTS Math 7 Elementary Linear Algebra PLOTS and ROTATIONS Example 1: Suppose you wish to use MatLab to plot a line segment connecting two points in the xy-plane. Recall that

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 NDSU Introduction to Matlab pg 1 Becoming familiar with MATLAB The console The editor The graphics windows The help menu Saving your data (diary) Solving N equations with N unknowns Least Squares Curve

More information

A Short Introduction to Matlab

A Short Introduction to Matlab A Short Introduction to Matlab Sheng Xu & Daniel Reynolds SMU Mathematics, 2015 1 What is Matlab? Matlab is a computer language with many ready-to-use powerful and reliable algorithms for doing numerical

More information

Math 375 Natalia Vladimirova (many ideas, examples, and excersises are borrowed from Profs. Monika Nitsche, Richard Allen, and Stephen Lau)

Math 375 Natalia Vladimirova (many ideas, examples, and excersises are borrowed from Profs. Monika Nitsche, Richard Allen, and Stephen Lau) Natalia Vladimirova (many ideas, examples, and excersises are borrowed from Profs. Monika Nitsche, Richard Allen, and Stephen Lau) January 24, 2010 Starting Under windows Click on the Start menu button

More information

Learning from Data Introduction to Matlab

Learning from Data Introduction to Matlab Learning from Data Introduction to Matlab Amos Storkey, David Barber and Chris Williams a.storkey@ed.ac.uk Course page : http://www.anc.ed.ac.uk/ amos/lfd/ This is a modified version of a text written

More information

A0B17MTB Matlab. Part #2. Miloslav Čapek Viktor Adler, Pavel Valtr. Department of Electromagnetic Field B2-634, Prague

A0B17MTB Matlab. Part #2. Miloslav Čapek Viktor Adler, Pavel Valtr. Department of Electromagnetic Field B2-634, Prague 017MT Matlab Part #2 Miloslav Čapek miloslav.capek@fel.cvut.cz Viktor dler, Pavel Valtr Department of Electromagnetic Field 2-634, Prague Learning how to Complex numbers Matrix creation Operations with

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

CS129: Introduction to Matlab (Code)

CS129: Introduction to Matlab (Code) CS129: Introduction to Matlab (Code) intro.m Introduction to Matlab (adapted from http://www.stanford.edu/class/cs223b/matlabintro.html) Stefan Roth , 09/08/2003 Stolen

More information

MATLAB QUICK START TUTORIAL

MATLAB QUICK START TUTORIAL MATLAB QUICK START TUTORIAL This tutorial is a brief introduction to MATLAB which is considered one of the most powerful languages of technical computing. In the following sections, the basic knowledge

More information

MATLAB for Image Processing. April 2018 Rod Dockter

MATLAB for Image Processing. April 2018 Rod Dockter MATLAB for Image Processing April 2018 Rod Dockter Outline Introduction to MATLAB Basics & Examples Image Processing with MATLAB Basics & Examples What is MATLAB? MATLAB = Matrix Laboratory MATLAB is a

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

Scientific Computing Lecture 1: MATLAB fundamentals

Scientific Computing Lecture 1: MATLAB fundamentals Scientific Computing Lecture 1: MATLAB fundamentals InFoMM CDT Mathematical Institute University of Oxford Andrew Thompson (slides by Stuart Murray) Lecture I: MATLAB fundamentals What is MATLAB? MATLAB

More information

Matlab Tutorial. Yi Gong

Matlab Tutorial. Yi Gong Matlab Tutorial Yi Gong 2011-1-7 Contact Info Keep an eye on latest announcement on course website Office Hours @ HFH 3120B M 10am-12pm, W 12pm-2pm, F 3pm-5pm Discussion Fri 2pm-2:50pm @PHELPS 1401 Email:

More information

MATLAB Premier. Middle East Technical University Department of Mechanical Engineering ME 304 1/50

MATLAB Premier. Middle East Technical University Department of Mechanical Engineering ME 304 1/50 MATLAB Premier Middle East Technical University Department of Mechanical Engineering ME 304 1/50 Outline Introduction Basic Features of MATLAB Prompt Level and Basic Arithmetic Operations Scalars, Vectors,

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

Prof. Manoochehr Shirzaei. RaTlab.asu.edu

Prof. Manoochehr Shirzaei. RaTlab.asu.edu RaTlab.asu.edu Introduction To MATLAB Introduction To MATLAB This lecture is an introduction of the basic MATLAB commands. We learn; Functions Procedures for naming and saving the user generated files

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

Designing Applications that See Lecture 4: Matlab Tutorial

Designing Applications that See Lecture 4: Matlab Tutorial stanford hci group / cs377s Designing Applications that See Lecture 4: Matlab Tutorial Dan Maynes-Aminzade 23 January 2007 Designing Applications that See http://cs377s.stanford.edu Reminders Assignment

More information

Introduction to Matlab

Introduction to Matlab Introduction to Matlab Christopher K. I. Williams Division of Informatics, University of Edinburgh October 1999 Background This document has the objective of introducing you to some of the facilities available

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

6.094 Introduction to MATLAB January (IAP) 2009

6.094 Introduction to MATLAB January (IAP) 2009 MIT OpenCourseWare http://ocw.mit.edu 6.094 Introduction to MATLAB January (IAP) 2009 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms. 6.094 Introduction

More 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

Getting Started with MATLAB

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

Summer 2009 REU: Introduction to Matlab

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

MATLAB TUTORIAL FOR MATH/CHEG 305

MATLAB TUTORIAL FOR MATH/CHEG 305 MATLAB TUTORIAL FOR MATH/CHEG 305 February 1, 2002 Contents 1 Starting Matlab 2 2 Entering Matrices, Basic Operations 2 3 Editing Command Lines 4 4 Getting Help 4 5 Interrupting, Quitting Matlab 5 6 Special

More information

Why use MATLAB? Mathematcal computations. Used a lot for problem solving. Statistical Analysis (e.g., mean, min) Visualisation (1D-3D)

Why use MATLAB? Mathematcal computations. Used a lot for problem solving. Statistical Analysis (e.g., mean, min) Visualisation (1D-3D) MATLAB(motivation) Why use MATLAB? Mathematcal computations Used a lot for problem solving Statistical Analysis (e.g., mean, min) Visualisation (1D-3D) Signal processing (Fourier transform, etc.) Image

More information

An Introductory Tutorial on Matlab

An Introductory Tutorial on Matlab 1. Starting Matlab An Introductory Tutorial on Matlab We follow the default layout of Matlab. The Command Window is used to enter MATLAB functions at the command line prompt >>. The Command History Window

More information

EE 301 Signals & Systems I MATLAB Tutorial with Questions

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

More information

Introduction to MATLAB Programming. Chapter 3. Linguaggio Programmazione Matlab-Simulink (2017/2018)

Introduction to MATLAB Programming. Chapter 3. Linguaggio Programmazione Matlab-Simulink (2017/2018) Introduction to MATLAB Programming Chapter 3 Linguaggio Programmazione Matlab-Simulink (2017/2018) Algorithms An algorithm is the sequence of steps needed to solve a problem Top-down design approach to

More information

MATLAB: The Basics. Dmitry Adamskiy 9 November 2011

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

More information

Introduction to Matlab

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

Numerical Methods Lecture 1

Numerical Methods Lecture 1 Numerical Methods Lecture 1 Basics of MATLAB by Pavel Ludvík The recommended textbook: Numerical Methods Lecture 1 by Pavel Ludvík 2 / 30 The recommended textbook: Title: Numerical methods with worked

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

Overview. Lecture 13: Graphics and Visualisation. Graphics & Visualisation 2D plotting. Graphics and visualisation of data in Matlab

Overview. Lecture 13: Graphics and Visualisation. Graphics & Visualisation 2D plotting. Graphics and visualisation of data in Matlab Overview Lecture 13: Graphics and Visualisation Graphics & Visualisation 2D plotting 1. Plots for one or multiple sets of data, logarithmic scale plots 2. Axis control & Annotation 3. Other forms of 2D

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

1.1 ABOUT MATLAB and MATLAB GUI (Graphical User Interface)

1.1 ABOUT MATLAB and MATLAB GUI (Graphical User Interface) Chapter 1 Introduction The Taylor Series is one of the most important tools in numerical analysis. It constitutes the foundation of numerical methods and will be used in most of the chapters of this text.

More information

Schedule. Matlab Exam. Documentation. Program Building Blocks. Dynamics Makeup Exam. Matlab Exam. Semester Summary and Wrap up.

Schedule. Matlab Exam. Documentation. Program Building Blocks. Dynamics Makeup Exam. Matlab Exam. Semester Summary and Wrap up. Schedule Dynamics Makeup Exam Thursday, May 1, 2:00 p.m., Estabrook 111 3 problems, covers modules 3 & 4 You may bring 1 sheet of notes Matlab Exam See next slide Semester Summary and Wrap up Wednesday,

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

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