dgesv reference implementation of LAPACK MATLAB (\) CPU time (s) Matrix dimension
|
|
- Susan Dorsey
- 5 years ago
- Views:
Transcription
1 MATLAB Plan ffl Introduction to Matlab Matrices Mathematical expressions C vs. Matlab Working with Matlab ffl Graphics Functions of one variable Styles, labels & titles Functions of two variables ffl Matlab Scripts Script basics Selection Iteration & vectorization Functions Introductory Course on Scientific Programming Matlab Introductory Course on Scientific Programming Matlab Introduction Matlab is an integrated environment for computation, simulation and visualization. + High level programming language ( mathematical syntax") + Many application specific algorithms (optimisation, ODE's, PDE's, approximation, statistics,...) + Fast development of complex codes + Good support for visualization Slow (inefficient memory handling, limited compiler) Large memory requirements Not available on state of the art computers Working with matrices Matlab is designed for matrix computations and many functions accept matrices and/or vectors as arguments. m n-matrix with elements a ij is defined by A=[a,..., a n ;...; a m,..., a mn ] (The commas can be replaced by blanks.) Automatic type determination and storage allocation. The results of all computations are displayed by default. This output can be supressed by adding a trailing semicolon. >> A = [ 2 ; 3 4 ; 5,6 ] A = >> B = [ 5 ; 7 3]; >> size(a) % Return # of rows & cols 3 2
2 Working with matrices (cont.) The elements of a matrix can be accessed by A(i,j), where» i» m,» j» n. If i and/or j is a vector, a matrix is returned. Logical subscripting selects elements based on some logical and/or relational expression. zeros(m,n) and ones(m,n) functions returning matrices with all elements are 0 and respectively. Vectors can be created using the colon operator, min : step : max which produces an row vector. The complex conjugate transpose operator ' can be used to obtain a column vector. >> b = ( : 2 : 5)' b = 3 5 Matrix subscripting >> A = [ 2 ; 3 4] A = >> A(2,) % Element in row 2, column 3 >> A(:,2) % Second column 2 4 >> A(,:) % First row 2 >> B=[ 2 3 ; ; 7 8 9]; >> B(:2,2:3) % Extract submatrix Introductory Course on Scientific Programming Matlab Introductory Course on Scientific Programming Matlab Mathematical expressions Operator Effect +,-,*,/ as in math () specify evaluation order ^ n power left division ( linear solve") Operators work for matrices and scalars. Precedence as in mathematics. >> A = [0 5 5 ; ; 6 8 8]; >> x = ones(3,); >> y = 3*(A*x)' y = >> z = A y' z = Mathematical functions Complex arithmetics: >> x = +i; >> y = -2*i; >> z = x*y z = i (i = p unless redefined.) Matlab provides a large number of elementary math functions, e.g. cos, exp, sqrt, abs, log. Most elementary functions work with matrices, >> x = 0 : 2*pi/00 : 2*pi; >> y = sin(x); (pi = ß) For more information: >> help elfun (elementary math) >> help specfun (specialized math) >> help matfun (matrix)
3 Element-by-element operations An arithmetic operator preceded by a period (.) acts on the elements of an array and does not follow the rules of linear algebra. Polynomial interpolation Determine the polynomial p(x) passing through x 2 3 p(x) 3 Expression Z=X.*Y Z=X./Y Z=X.^p Example, Effect Z i;j ψ X i;j Y i;j Z i;j ψ X i;j =Y i;j Z i;j ψ X p i;j Mathematical solution Let p(x) = a + a 2 x + a 3 x 2, then C A a a 2 a 3 C A = 0 C A ) a = C A >> A=[ 2 ; 3 4]; >> A*A % Matrix multiplication >> A.*A % Element multiplication Matlab >> x = (:3)'; >> p = [;;3]; >> M = [ones(size(x)), x, x.^2]; >> a = M p a = 3-3 Introductory Course on Scientific Programming Matlab Introductory Course on Scientific Programming Matlab A least squares problem Determine a linear approximation l(x) to the polynomial p(x) passing through x 2 3 p(x) 3 Least Squares Solution Find coefficients in l(x) = b + b 2 x, such that the discrete norm kl(x) p(x)k 2 is minimized C vs. Matlab dgesv reference implementation of LAPACK MATLAB (\) Matlab >> x = (:3)'; >> p = [;;3]; >> M = [ones(size(x)), x]; >> b = M p b = >> norm(m*b-p,2) % Compute residual norm CPU time (s) Matrix dimension Full linear solve
4 CPU time (s) Introductory Course on Scientific Programming M Matlab Desktop Matlab a sample session Figur Scrip (emac A Christer christe@nad C vs. Matlab Optimized C code ( O2) MATLAB Number of unknowns Burgers' equation, upwind scheme (Computer exercise 5.3) Introductory Course on Scientific Programming Matlab Introductory Course on Scientific Programming Matlab Working with matlab Matlab desktop Typing matlab at the Unix prompt opens the Matlab desktop. Matlab is terminated by the command exit. Any command entered at the Matlab prompt is evaluated immediately. Working with matlab (cont.) Windows available on desktop (view menu): emacs For writing Matlab scripts (m-files) and functions (Lecture 3 ). Scripts are run from the Matlab prompt. Matlab 6 has its own combined editor/debugger. Figure window(s) Opened by Matlab for displaying graphics (Lecture 2 ). Command Window Command History Current Directory Workspace Launch Pad Help View Menu Matlab prompt Cut & paste to command window GUI to file system List current variables (with size) Help & tools sorted by toolbox Launch graphical help browser Windows can be resized and moved outside of desktop ( )
5 Some useful commands help doc clear save load clc format!cmd print Some useful commands plain text help graphical help browser Remove variables from workspace Save variables in workspace Load variables from file Clear screen Set output format Execute Unix command cmd Print figure window MATLAB 2 Some of these commands may need additional parameters. Matlab graphics Graphics in Matlab is displayed in the current figure window. Figure windows are opened by figure and closed by close. A figure is made active by figure(h), where H is the handle (integer returned when a window is opened). Matlab will open a figure window if one doesn't exist when a graphics function is called. 2D graphs Functions of one variable are typically displayed using plot(x, y,..., x n, y n); The elements of y i are plotted versus the elements of x i. The values are connected with straight lines (linear interpolation). Help on graphics: >> help graph2d (2D graphs) >> help graph3d (3D graphs) >> help specgraph (special, e.g. 4d") >> x = 0 : 2*pi/00 : 2*pi; >> y = exp(-abs(x-pi)); >> plot(x, y, x, sin(x))
6 2D graphs (cont.) The contents of the current figure are replaced when a new plot command is issued. The hold command can be used to add plots to an existing graph (c.f. previous slide), >> plot(x,y) >> hold on >> plot(x, sin(x)) >> hold off hold off returns to default mode. cla and clf can be used to clear the figure window. Curve styles plot(x, y, style,..., x n, y n, style n); Each curve style is a string of 3 characters: ffl Colour: e.g. 'b' (blue) or 'r' (red) ffl Linestyle: e.g. '-' (solid) or ':' (dotted) ffl Marker: e.g. 'o' (circles) or 's' (squares) See help plot for more styles. Zooming zoom on turns zoom on for the current figure. Left-clicking zooms in, right-clicking zooms out. For 2D graphs an area can be selected with the left mouse button. NB! cla, clf, hold works for 3D graphs as well. >> x = 0:2*pi/00:2*pi; y0=exp(-abs(x-pi)); >> y = sin(x); y2 = x/(2*pi); >> plot(x,y0,'bo-',x,y,'r',x,y2,'k:') Labels & Titles Command Effect xlabel('...') Adds text beside the x-axis title('...') Adds text at top of figure leg(...) Add leg to current graph >> x = 0 : 2*pi/00 : 2*pi; >> L = plot(x, cos(x), x, sin(x)); >> xlabel('x') >> ylabel('y(x)') >> title('trigonometric functions') >> leg(l, 'cos(x)', 'sin(x)') Special 2D graphs Logarithmic plots (base 0) For some plots logarithmic scale is more informative. semilogx(...) semilogy(...) loglog(...) Same interface as for plot. Polar plots polar(theta, r, style); Log. scale on x-axis Log. scale on y-axis Log. scale on x- and y-axes Polar coordinates with radius r and angle. The curve style is optional. Complex data By default only real part plotted. If a single complex array is passed to plot the imaginary part is plotted versus the real part.
7 Subplots Multiple plots can be displayed in the same figure by subplot. subplot(m, n, p) Divides the figure window into an m n-matrix of subplots", and makes subplot p active (numbered rowwise from ). Axis control The scaling and appearance of axes can be controlled, e.g. axis equal axis square grid axis(x 0 ;x ;y 0 ;y ) set aspect ratio equal make axis box square display grid lines set axis scaling >> x=0:2*pi/00:2*pi; >> subplot(2,2,); plot(x,sin(x),x,cos(x)) >> subplot(2,2,2); plot(cos(x),sin(x)) >> subplot(2,2,3); plot(exp(i*x)) >> subplot(2,2,4); polar(x,ones(size(x))) Titles & labels can be given for each subplot. >> x=0:2*pi/00:2*pi; >> subplot(2,,);plot(cos(x),sin(x)) >> grid >> subplot(2,,2);plot(cos(x),sin(x)) >> axis([ ]) >> axis square 3D Graphs: surface plots A function of two variables can be visualized by surf(x, Y, Z, C) where Z = Z(X; Y ) 2 R m n, X 2 R m n or X 2 R n (x-coords), Y 2 R m n or X 2 R m (y-coords) and C 2 R m n determines colour scaling Surface plots (cont.) C=Z is assumed if C not passed explicitly to surf. mesh has the same interface as surf, but plots a parametric mesh instead of a surface. surf and mesh require rectangular grids. The function [X,Y] = meshgrid(x,y) generates matrices X; Y from the vectors x; y. It is assumed that y = x if y is omitted. Use help graph3d for more information on 3D graphs. >> [X,Y]=meshgrid(-8:.5:8); >> R = sqrt(x.^2+y.^2) + e-6; >> subplot(2,,); mesh(x,y,sin(r)./r,r); >> title('mesh()') >> subplot(2,,2); surf(x,y,sin(r)./r); >> title('surf()')
8 Appearance of surface plots 3D Graphs: contour plots contour(x, Y, Z, V) plots the level sets of z(x; y), i.e. curves (μx; μy) : z(μx; μy) = constant >> surf(x,y,z) >> colormap(summer) >> shading interp >> colorbar('vert') shading: controls colour shading flat, interp or faceted (default) colorbar('...'): show colour scale 'vert' (vertical) or 'horiz' (horizontal) colormap: maps function value to colour colormap(a), A 2 R n 3 Rows interpreted as RGB-values (2 [0; ]) See help graph3d for predefined. X, Y and Z should be defined as for surf. V is either an integer specifying the number of curves or a vector specifying the constant values. It can be omitted. >> [X,Y] = meshgrid(0:.0:pi); >> H=contour(X,Y,cos(X.*Y)); >> clabel(h) clabel labels the plotted curves. Rotating & Printing Rotating rotate3d on turns on mouse-based 3D rotation. Pressing the mouse button allows the axis to be rotated. When the button is released the contents of the figure window are updated. view can be used to set the position from which a 3D graph is viewed, e.g. by view([x,y,z]). MATLAB 3 Printing graphics The current figure can be printed using print. The switch -Pprinter determines which printer to use (Unix & VMS only). print -ddevice figure to file. filename prints the current device specifies the format, e.g. psc (postscript colour, default) or jpeg.
9 Matlab scripts Matlab commands can be collected in scripts which are similar to C programs. Matlab scripts are written in a text editor, e.g. emacs or the Matlab editor/debugger. The file should have the suffix.m to be called from within Matlab. A script stored in file.m is executed by file in the Matlab prompt. Example, file mtx.m: A = [ ; ; ; ]; Script execution (Matlab): >> whos >> mtx >> whos Name Size Bytes Class A 4x4 28 double array Grand total is 6 elements using 28 bytes Matlab scripts (cont.) Each command in a script should be terminated by a new line, ; or,. A command can span several lines if a line is terminated by three periods (...). All text following a % is interpreted as a comment. Comments in the beginning of a file are interpreted as user help. Example, file mtx.m: % This script defines a matrix A = [ ; ;... Matlab: ; ]; >> help mtx >> This script defines a matrix. Selection : if if expression else The expression is true if the real part has all non-zero elements (i.e. complex matrix-valued). Selection : switch switch (switch-expression ) case case-expression case case-expression2 Some Operators <, <=, >, >= less than,... ==, ~= equal to, not equal to & Logical AND Logical OR ~ Logical NOT Example, [m,n] = size(a); if (m ~= n) disp('matrix A is not square')... otherwise Works as in C, but case-expression can be scalars and strings. There is no statement corresponding to break" in Matlab.
10 Iteration : while while expression Example, Newton-iteration on x cos x: x = 0; dx=; while (abs(dx) > e-0) f = x - cos(x); fprime = + sin(x); dx x = -f / fprime; = x + dx; fprintf('%20.2e %20.2e n', x, dx); Program execution: >> newton e e e e e e e e e e e e+00 Iteration : for for variable =matrix The loop body is executed once for each element in matrix. variable takes on the values of the matrix elements in column-wise order. >> A=[ 3.4 ; -5 0] A = >> for i=a, disp(i), Note: The colon operator should be used if possible to avoid memory allocation. for i=:0 better than I=:0; for i=i Vectorization Matlab is optimized for working with matrices. One should try to use matrices & vectors as much as possible. Example, outer product implementation of y = Ax (assuming A & x defined): [m,n] = size(a); y = zeros(m,); for j=:n for i=:m y(i) = y(i) + A(i,j)*x(j); 30.5 CPU-seconds for A 2 R y=a*x; requires 0.2 CPU-seconds. Simple loops can often be reformulated in terms of vectors. Matlab functions function [return-values ] = dummy (...) Functions in Matlab are m-files which can accept input arguments and return output values. More than one value can be returned. A function must be stored in a separate file, except local" functions which can be called from within another function only. A function is called by its filename. Example, file avg.m: function m = Donald_Duck(x) % Compute average of elements in x. m = sum(x) / length(x); Donald Duck is a dummy name which is never used. The function is called by avg.
11 Matlab functions (cont.) All arguments are passed by value in Matlab. Call by reference not possible. If a value is supposed to change it must be returned from the function. File increase.m: function i = increase(j) j = j+; i = j; Matlab: >> i=; >> increase(i); disp(i) Input & Output disp can be used for basic output in Matlab. It supports real and complex matrices, scalars,... More control can be obtained by using fprintf, fprintf(fid, format,...) The output (as specified by the format string) and variables are printed to file identifier fid, or the screen if fid is omitted. fprintf has limited support for matrices. It is possible to open files with fopen. >> i=increase(i); disp(i) 2 Example, returning several values: function [minval,maxval]=minmax(x) minval=min(x); maxval=max(x); Input from keyboard can be read using input(string ) The function input displays string, and returns the value entered. fscanf exists but can be used to read from files only. Input & Output (cont.) A number can be converted into a string by num2str. str2num performs the reverse conversion. Example (io.m): x = input('enter a vector: '); disp(['you entered a vector of length ',... num2str(length(x))]); fprintf('%e n', x); Matlab: >> io Enter a vector: (:5)' You entered a vector of length e e e e e+00 Executing functions by strings feval(str,...) evaluates the function whose name is given in the string str with arguments... sin(x) and feval('sin', x) equivalent. Can be used to pass functions to functions ( function pointers"). Example, solving y 0 (t) = y(t) 2, y(0) = ode45 solves initial value problems for ODE's. [T,Y] = ode45('odefile', [t0 t], y0). Y contains approximate solution at times in T 2 [t 0 ;t ]. Function yprime.m: function yp = yprime(t,y) yp = -y.^2; % (Vector notation to be on safe side)
12 Example: Solving an ODE Script solve.m: [T,Y] = ode45('yprime', [0,20], ); plot(t,y) xlabel('t'); ylabel('y(t)'); title('y''(t) = -y(t)^2, y(0)='); Storage class Variables in Matlab (and C) have local storage class by default. A variable in a function can be declared persistent to maintain its value between function calls (c.f. static in C). A persistent variable is initalized to the empty matrix []. Example, function test persistent i if (isempty(i)), i=; else i=i+; fprintf('this is function call %d n',i); Matlab: ode45 contains several function evaluations on the form feval(odefile, t, y). >> test This is function call >> test This is function call 2 >> test This is function call 3 Storage class It is sometimes convenient to have global variables. An identifier declared global prior to its initialization is added to the global symbol table. It can be used inside all functions declaring it. Example, Object orientation & GUI Matlab supports (emulated) object orientation. Messy to program since variables can not be passed by reference. Many routines for fast creation of GUI's. function dummy() global G disp(g) Matlab: >> global G >> dummy % Empty matrix, no output >> G=.0; >> dummy GUI for visualizing C computations (Colours screwed up when capturing image)
13 Introductory Course on Scientific Programming M home page Course home page for the introductory course is available at URL The html or you can enter and click your way there. A Christer christe@nad
Introduction to MATLAB
ELG 3125 - Lab 1 Introduction to MATLAB TA: Chao Wang (cwang103@site.uottawa.ca) 2008 Fall ELG 3125 Signal and System Analysis P. 1 Do You Speak MATLAB? MATLAB - The Language of Technical Computing ELG
More 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 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 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 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 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 informationIntroduction 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 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 informationMath Sciences Computing Center. University ofwashington. September, Fundamentals Making Plots Printing and Saving Graphs...
Introduction to Plotting with Matlab Math Sciences Computing Center University ofwashington September, 1996 Contents Fundamentals........................................... 1 Making Plots...........................................
More informationMath 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 informationWhat is Matlab? A software environment for interactive numerical computations
What is Matlab? A software environment for interactive numerical computations Examples: Matrix computations and linear algebra Solving nonlinear equations Numerical solution of differential equations Mathematical
More 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 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 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 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 informationFinding, 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 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 informationCDA6530: 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 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 informationPROGRAMMING WITH MATLAB WEEK 6
PROGRAMMING WITH MATLAB WEEK 6 Plot: Syntax: plot(x, y, r.- ) Color Marker Linestyle The line color, marker style and line style can be changed by adding a string argument. to select and delete lines
More informationCDA6530: 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 informationCDA5530: 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 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 informationQuick MATLAB Syntax Guide
Quick MATLAB Syntax Guide Some useful things, not everything if-statement Structure: if (a = = = ~=
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 informationGetting started with MATLAB
Sapienza University of Rome Department of economics and law Advanced Monetary Theory and Policy EPOS 2013/14 Getting started with MATLAB Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Outline
More informationIntroduction 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 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 informationAn 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 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 informationInlichtingenblad, matlab- en simulink handleiding en practicumopgaven IWS
Inlichtingenblad, matlab- en simulink handleiding en practicumopgaven IWS 1 6 3 Matlab 3.1 Fundamentals Matlab. The name Matlab stands for matrix laboratory. Main principle. Matlab works with rectangular
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 informationProgramming 1. Script files. help cd Example:
Programming Until now we worked with Matlab interactively, executing simple statements line by line, often reentering the same sequences of commands. Alternatively, we can store the Matlab input commands
More 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 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 informationEng Marine Production Management. Introduction to Matlab
Eng. 4061 Marine Production Management Introduction to Matlab What is Matlab? Matlab is a commercial "Matrix Laboratory" package which operates as an interactive programming environment. Matlab is available
More informationMechanical Engineering Department Second Year (2015)
Lecture 7: Graphs Basic Plotting MATLAB has extensive facilities for displaying vectors and matrices as graphs, as well as annotating and printing these graphs. This section describes a few of the most
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 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 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. 1. The MATLAB Windows. 2. The Command Windows. 3. Simple scalar or number operations
MATLAB Tutorial The following tutorial has been compiled from several resources including the online Help menu of MATLAB. It contains a list of commands that will be directly helpful for understanding
More 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 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 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 informationProf. 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 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 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 informationLab #1 Revision to MATLAB
Lab #1 Revision to MATLAB Objectives In this lab we would have a revision to MATLAB, especially the basic commands you have dealt with in analog control. 1. What Is MATLAB? MATLAB is a high-performance
More informationGetting 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 informationIntroduction to Matlab
Introduction to Matlab Enrique Muñoz Ballester Dipartimento di Informatica via Bramante 65, 26013 Crema (CR), Italy enrique.munoz@unimi.it Contact Email: enrique.munoz@unimi.it Office: Room BT-43 Industrial,
More informationIntroduction to Matlab
Introduction to Matlab What is Matlab? Matlab is a commercial "Matrix Laboratory" package which operates as an interactive programming environment. Matlab is available for PC's, Macintosh and UNIX systems.
More informationHere is a quick introduction to Matlab and a couple of its symbolic and control functions.
Some Matlab 1 Here is a quick introduction to Matlab and a couple of its symbolic and control functions. Matlab is an interpreted language. When you enter a command in the Command window, the line is executed
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 informationOutline. CSE 1570 Interacting with MATLAB. Starting MATLAB. Outline. MATLAB Windows. MATLAB Desktop Window. Instructor: Aijun An.
CSE 170 Interacting with MATLAB Instructor: Aijun An Department of Computer Science and Engineering York University aan@cse.yorku.ca Outline Starting MATLAB MATLAB Windows Using the Command Window Some
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 informationIntroduction to MATLAB
Introduction to MATLAB Violeta Ivanova, Ph.D. MIT Academic Computing violeta@mit.edu http://web.mit.edu/violeta/www/iap2006 Topics MATLAB Interface and Basics Linear Algebra and Calculus Graphics Programming
More informationChapter 2 (Part 2) MATLAB Basics. dr.dcd.h CS 101 /SJC 5th Edition 1
Chapter 2 (Part 2) MATLAB Basics dr.dcd.h CS 101 /SJC 5th Edition 1 Display Format In the command window, integers are always displayed as integers Characters are always displayed as strings Other values
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 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 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 informationMATLAB 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 informationMATLAB Functions and Graphics
Functions and Graphics We continue our brief overview of by looking at some other areas: Functions: built-in and user defined Using M-files to store and execute statements and functions A brief overview
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 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 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 informationThe Department of Engineering Science The University of Auckland Welcome to ENGGEN 131 Engineering Computation and Software Development
The Department of Engineering Science The University of Auckland Welcome to ENGGEN 131 Engineering Computation and Software Development Chapter 7 Graphics Learning outcomes Label your plots Create different
More informationINTRODUCTION TO NUMERICAL ANALYSIS
INTRODUCTION TO NUMERICAL ANALYSIS Cho, Hyoung Kyu Department of Nuclear Engineering Seoul National University 0. MATLAB USAGE 1. Background MATLAB MATrix LABoratory Mathematical computations, modeling
More informationOutline. CSE 1570 Interacting with MATLAB. Starting MATLAB. Outline (Cont d) MATLAB Windows. MATLAB Desktop Window. Instructor: Aijun An
CSE 170 Interacting with MATLAB Instructor: Aijun An Department of Computer Science and Engineering York University aan@cse.yorku.ca Outline Starting MATLAB MATLAB Windows Using the Command Window Some
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 for COMP24111 (includes exercise 1)
Matlab Tutorial for COMP24111 (includes exercise 1) 1 Exercises to be completed by end of lab There are a total of 11 exercises through this tutorial. By the end of the lab, you should have completed the
More informationA QUICK INTRODUCTION TO MATLAB
A QUICK INTRODUCTION TO MATLAB Very brief intro to matlab Basic operations and a few illustrations This set is independent from rest of the class notes. Matlab will be covered in recitations and occasionally
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 informationIntroduction 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 informationIntroduction 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 informationA QUICK INTRODUCTION TO MATLAB. Intro to matlab getting started
A QUICK INTRODUCTION TO MATLAB Very brief intro to matlab Intro to matlab getting started Basic operations and a few illustrations This set is indepent from rest of the class notes. Matlab will be covered
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 informationECE Lesson Plan - Class 1 Fall, 2001
ECE 201 - Lesson Plan - Class 1 Fall, 2001 Software Development Philosophy Matrix-based numeric computation - MATrix LABoratory High-level programming language - Programming data type specification not
More informationHERIOT-WATT UNIVERSITY DEPARTMENT OF COMPUTING AND ELECTRICAL ENGINEERING. B35SD2 Matlab tutorial 1 MATLAB BASICS
HERIOT-WATT UNIVERSITY DEPARTMENT OF COMPUTING AND ELECTRICAL ENGINEERING Objectives: B35SD2 Matlab tutorial 1 MATLAB BASICS Matlab is a very powerful, high level language, It is also very easy to use.
More informationA Quick Tutorial on MATLAB. Zeeshan Ali
A Quick Tutorial on MATLAB Zeeshan Ali MATLAB MATLAB is a software package for doing numerical computation. It was originally designed for solving linear algebra type problems using matrices. It's name
More informationMatLab Just a beginning
MatLab Just a beginning P.Kanungo Dept. of E & TC, C.V. Raman College of Engineering, Bhubaneswar Introduction MATLAB is a high-performance language for technical computing. MATLAB is an acronym for MATrix
More informationLecture 2 Introduction to MATLAB. Dr.Tony Cahill
Lecture 2 Introduction to MATLAB Dr.Tony Cahill The MATLAB Environment The Desktop Environment Command Window (Interactive commands) Command History Window Edit/Debug Window Workspace Browser Figure Windows
More informationIntroduction and MATLAB Basics
Introduction and MATLAB Basics Lecture Computer Room MATLAB MATLAB: Matrix Laboratory, designed for matrix manipulation Pro: Con: Syntax similar to C/C++/Java Automated memory management Dynamic data types
More informationGetting To Know Matlab
Getting To Know Matlab The following worksheets will introduce Matlab to the new user. Please, be sure you really know each step of the lab you performed, even if you are asking a friend who has a better
More 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 informationMATLAB Guide to Fibonacci Numbers
MATLAB Guide to Fibonacci Numbers and the Golden Ratio A Simplified Approach Peter I. Kattan Petra Books www.petrabooks.com Peter I. Kattan, PhD Correspondence about this book may be sent to the author
More informationComputational Modelling 102 (Scientific Programming) Tutorials
COMO 102 : Scientific Programming, Tutorials 2003 1 Computational Modelling 102 (Scientific Programming) Tutorials Dr J. D. Enlow Last modified August 18, 2003. Contents Tutorial 1 : Introduction 3 Tutorial
More informationGRAPHICS AND VISUALISATION WITH MATLAB
GRAPHICS AND VISUALISATION WITH MATLAB UNIVERSITY OF SHEFFIELD CiCS DEPARTMENT Des Ryan & Mike Griffiths September 2017 Topics 2D Graphics 3D Graphics Displaying Bit-Mapped Images Graphics with Matlab
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 informationIntroduction to Programming in MATLAB
Introduction to Programming in MATLAB User-defined Functions Functions look exactly like scripts, but for ONE difference Functions must have a function declaration Help file Function declaration Outputs
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 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 information1 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 informationMATLAB 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 informationIntroduction to Matlab
Introduction to Matlab Matlab (MATrix LABoratory) will be the programming environment of choice for the numerical solutions developed in this textbook due to its wide availability and its ease of use.
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 informationObjectives. 1 Running, and Interface Layout. 2 Toolboxes, Documentation and Tutorials. 3 Basic Calculations. PS 12a Laboratory 1 Spring 2014
PS 12a Laboratory 1 Spring 2014 Objectives This session is a tutorial designed to a very quick overview of some of the numerical skills that you ll need to get started. Throughout the tutorial, the instructors
More informationMATLAB 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 informationIntroduction to MATLAB
Introduction to MATLAB Contents 1.1 Objectives... 1 1.2 Lab Requirement... 1 1.3 Background of MATLAB... 1 1.4 The MATLAB System... 1 1.5 Start of MATLAB... 3 1.6 Working Modes of MATLAB... 4 1.7 Basic
More informationIntroduction 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 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 information