Lecture 6 MATLAB programming (4) Dr.Qi Ying
|
|
- Opal Green
- 5 years ago
- Views:
Transcription
1 Lecture 6 MATLAB programming (4) Dr.Qi Ying
2 Objectives User-defined Functions Anonymous Functions Function name as an input argument Subfunctions and nested functions Arguments persistent variable
3 Anonymous Functions You can create a simple function without creating an M-file file_handle=@(argument list) expression For example, define an anonymous function f1: >> f1=@(x,y) x^2+y^2; >> f1(3,4) ans = 25
4 Anonymous Functions Anonymous function can include variables exist in the workspace where it is created: >> a=4;b=2; >> a*x^b; >> f2(3) ans = 36 Note that if you changed the variables a and b later, their values in the anonymous function does not change.
5 Function name as an input argument (function functions) Function functions: are functions whose input arguments include the names of other functions. Example: matlab contains a function function called fzero, which locates a zero of the function that is passed to it. Try: means get the handle of the matlab build-in function cos
6 Anonymous function as an input argument Don t need to get the handle of the function if you are using anonymous function as input. For example, using the matlab function fplot to make a plot of an anonymous function 20 >>f1=@(x) x^2-x-1; >>fplot(f1,[0,5]);
7 Example A simple plotter function quickplot( fun, xlim ) %QUICKPLOT Generate a quick plot of a function % generate x for plotting n_steps=100; x=linspace(xlim(1),xlim(2),n_steps); % linspace is a matlab build-in function, it is equivalent % to the following code: %step_size=(xlim(2)-xlim(1))/n_steps; %x=xlim(1):step_size:xlim(2); % evaluate the function y=fun(x); %plot plot(x,y);
8 Example A simple plotter >> quickplot(f1, [0, 5])??? Error using ==> mpower Matrix must be square. Error in Error in ==> quickplot at 13 y=fun(x); So, it looks like we need to have a vector version of the function f1: >> f1=@(x) x.^2-x-1; >> quickplot(f1, [0, 5])
9 Evaluate a string as a function eval: evaluate a character string as if it has been typed from the command window try: y=eval( sin(pi/4) ) x=0:10; y=eval( x.*x+3.*x+1 )
10 Another simple plotter function quickplot( funstr, xlim ) %QUICKPLOT Generate a quick plot of a function % funstr: is a string to evaluate n_steps=100; x=linspace(xlim(1),xlim(2),n_steps); % evaluate the function y=eval(funstr); plot(x,y);
11 Test the plotter It allows input from the user: Code for testplot.m fun=input('enter the expression you want to plot:','s'); xmin=input('enter the lower limit xmin:'); xmax=input('enter the upper limit xmax:'); quickplot(fun,[xmin xmax]); 5 4 >> testplot Enter the expression you want to plot:sin(x)*5 Enter the lower limit xmin:-pi Enter the upper limit xmax:pi
12 Subfunctions It is possible to place more than one function in a single file. The first function (which has the same name as the file itself) is the primary function. The other functions below it are subfunctions. Used as utility functions to implement the primary function. Only accessible to other functions in the same file.
13 Subfunctions my_function.m function my_function(x) a=subfunc1(x); b=subfunc2(x); function y=subfunc1(x) function y=subfunc2(x) This is the primary function These are subfunctions.
14 Nested functions Nested functions are functions that are defined entirely in the body of another function, called the host function. The are only visible to the host function and the same level nested functions. Host variables are visible to the nested function. Variables in the nested function is not visible to the host function.
15 Nested functions my_function.m function my_function(x) a=nestfunc1(x); b=nestfunc2(x); function y=nestfunc1(x) function y=nestfunc2(x)
16 Example Variable in the host function is visible to the nested function. function testnest( x ) nestsub1; fprintf('in testnest: x=%f\n',x); function nestsub1 fprintf('in sub1: x=%f\n',x); x=x+1; >> testnest(3) in sub1: x= in testnest: x=
17 Example A variable in the nested function with the same name as a variable in the host function: function testnest( x ) nestsub1(x); fprintf('in testnest: x=%f\n',x); function nestsub1(x) fprintf('in sub1: x=%f\n',x); x=x+1; >> testnest(3) in sub1: x= in testnest: x=
18 Argument related MATLAB functions nargin: returns the number of actual input arguments nargout: returns the number of actual output arguments
19 Example function [ r, theta ] = polar_value( x, y ) %POLAR_VALUE Converts (x,y) to (r, theta) if nargin ~= 2 msg='two input arguments are required.'; error(msg); Stop program execution and print out an error message if nargout ~=2 msg='two output arguments are preferred.'; warning(msg); Print out a warning message, program continues if x==0 & y==0 msg='both x and y are zero: angle is meaning less.'; warning(msg); % calculate the magnitude and angle r=sqrt(x.^2+y.^2); theta=atan2(y,x)*180/pi; % results in degrees % of function polar_value
20 Persistent variable Sometimes it is desirable to keep the value of a local variable in a function function y = testpersistent( x ) persistent n; if isempty(n) n=0; % initialize n n=n+x; fprintf('n=%f\n',n); A persistent variable is empty when it is first defined by the persistent keyword. It needs to be initialized before participating in any operations.
User Defined Functions
User Defined Functions 120 90 1 0.8 60 Chapter 6 150 0.6 0.4 30 0.2 180 0 210 330 240 270 300 Objectives Create and use MATLAB functions with both single and multiple inputs and outputs Learn how to store
More informationLecture 4: Complex Numbers Functions, and Data Input
Lecture 4: Complex Numbers Functions, and Data Input Dr. Mohammed Hawa Electrical Engineering Department University of Jordan EE201: Computer Applications. See Textbook Chapter 3. What is a Function? A
More informationLecture 5 MATLAB programming (3) Dr.Qi Ying
Lecture 5 MATLAB programming (3) Dr.Qi Ying Objectives User-defined Functions A Simple Example: factorial Write a program to calculate the factorial: N!=1, N=0 N!=N*(N-1)*(N-2) *3*2*1, N>0 n=input('please
More informationChapters 6-7. User-Defined Functions
Chapters 6-7 User-Defined Functions User-Defined Functions, Iteration, and Debugging Strategies Learning objectives: 1. Write simple program modules to implement single numerical methods and algorithms
More informationExample: A Four-Node Network
Node Network Flows Flow of material, energy, money, information, etc., from one place to another arc 6 Node Node arc 6 Node Node 5 Node 6 8 Goal: Ship All of the Over the Network to Meet All of the 6 6
More informationTentative Course Schedule, CRN INTRODUCTION TO SCIENTIFIC & ENGINEERING COMPUTING BIL 108E, CRN24023 LECTURE # 5 INLINE FUNCTIONS
Tentative Course Schedule, CRN 24023 INTRODUCTION TO SCIENTIFIC & ENGINEERING COMPUTING BIL 108E, CRN24023 Dr. S. Gökhan Technical University of Istanbul Week Date Topics 1 Feb. 08 Computing 2 Feb. 15
More information1 >> Lecture 3 2 >> 3 >> -- Functions 4 >> Zheng-Liang Lu 169 / 221
1 >> Lecture 3 2 >> 3 >> -- Functions 4 >> Zheng-Liang Lu 169 / 221 Functions Recall that an algorithm is a feasible solution to the specific problem. 1 A function is a piece of computer code that accepts
More informationWhat is a Function? EF102 - Spring, A&S Lecture 4 Matlab Functions
What is a Function? EF102 - Spring, 2002 A&S Lecture 4 Matlab Functions What is a M-file? Matlab Building Blocks Matlab commands Built-in commands (if, for, ) Built-in functions sin, cos, max, min Matlab
More informationMATLAB. Input/Output. CS101 lec
MATLAB CS101 lec24 Input/Output 2018-04-18 MATLAB Review MATLAB Review Question ( 1 2 3 4 5 6 ) How do we access 6 in this array? A A(2,1) B A(1,2) C A(3,2) D A(2,3) MATLAB Review Question ( 1 2 3 4 5
More informationLecture 7 Symbolic Computations
Lecture 7 Symbolic Computations The focus of this course is on numerical computations, i.e. calculations, usually approximations, with floating point numbers. However, Matlab can also do symbolic computations,
More informationA = [1, 6; 78, 9] Note: everything is case-sensitive, so a and A are different. One enters the above matrix as
1 Matlab Primer The purpose of these notes is a step-by-step guide to solving simple optimization and root-finding problems in Matlab To begin, the basic object in Matlab is an array; in two dimensions,
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 informationClasses 7-8 (4 hours). Graphics in Matlab.
Classes 7-8 (4 hours). Graphics in Matlab. Graphics objects are displayed in a special window that opens with the command figure. At the same time, multiple windows can be opened, each one assigned a number.
More informationMath 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 informationNatSciLab - Numerical Software Introduction to MATLAB
Outline 110112 NatSciLab - Numerical Software Introduction to MATLAB Onur Oktay Jacobs University Bremen Spring 2010 Outline 1.m files 2 Programming Branching (if, switch) Loops (for, while) 3 Anonymous
More informationLab of COMP 406 Introduction of Matlab (III) Programming and Scripts
Lab of COMP 406 Introduction of Matlab (III) Programming and Scripts Teaching Assistant: Pei-Yuan Zhou Contact: cspyzhou@comp.polyu.edu.hk Lab 3: 26 Sep., 2014 1 Open Matlab 2012a Find the Matlab under
More informationEL2310 Scientific Programming
(pronobis@kth.se) Overview Overview Wrap Up More on Scripts and Functions Basic Programming Lecture 2 Lecture 3 Lecture 4 Wrap Up Last time Loading data from file: load( filename ) Graphical input and
More information6 Appendix B: Quick Guide to MATLAB R
6 Appendix B: Quick Guide to MATLAB R 6.1 Introduction In this course we will be using the software package MATLAB R. Version 17.12.0, Release R2011a has been installed in Foster 100, the labs on the third
More informationChapter 6 User-Defined Functions. dr.dcd.h CS 101 /SJC 5th Edition 1
Chapter 6 User-Defined Functions dr.dcd.h CS 101 /SJC 5th Edition 1 MATLAB Functions M-files are collections of MATLAB statements that stored in a file, called a script file. Script files share the command
More informationSECTION 2: PROGRAMMING WITH MATLAB. MAE 4020/5020 Numerical Methods with MATLAB
SECTION 2: PROGRAMMING WITH MATLAB MAE 4020/5020 Numerical Methods with MATLAB 2 Functions and M Files M Files 3 Script file so called due to.m filename extension Contains a series of MATLAB commands The
More informationHow to learn MATLAB? Some predefined variables
ECE-S352 Lab 1 MATLAB Tutorial How to learn MATLAB? 1. MATLAB comes with good tutorial and detailed documents. a) Select MATLAB help from the MATLAB Help menu to open the help window. Follow MATLAB s Getting
More 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 informationChemical Engineering 541
Chemical Engineering 541 Computer Aided Design Methods Matlab Tutorial 1 Overview 2 Matlab is a programming language suited to numerical analysis and problems involving vectors and matricies. Matlab =
More informationUniversity of Alberta
A Brief Introduction to MATLAB University of Alberta M.G. Lipsett 2008 MATLAB is an interactive program for numerical computation and data visualization, used extensively by engineers for analysis of systems.
More informationMATLAB 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 informationCS227-Scientific Computing. Lecture 3-MATLAB Programming
CS227-Scientific Computing Lecture 3-MATLAB Programming Contents of this lecture Relational operators The MATLAB while Function M-files vs script M-files The MATLAB for Logical Operators The MATLAB if
More informationMAT 275 Laboratory 1 Introduction to MATLAB
MATLAB sessions: Laboratory 1 1 MAT 275 Laboratory 1 Introduction to MATLAB MATLAB is a computer software commonly used in both education and industry to solve a wide range of problems. This Laboratory
More informationPractice Reading for Loops
ME 350 Lab Exercise 3 Fall 07 for loops, fprintf, if constructs Practice Reading for Loops For each of the following code snippets, fill out the table to the right with the values displayed when the code
More informationME 121 MATLAB Lesson 01 Introduction to MATLAB
1 ME 121 MATLAB Lesson 01 Introduction to MATLAB Learning Objectives Be able run MATLAB in the MCECS computer labs Be able to perform simple interactive calculations Be able to open and view an m-file
More informationA 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 informationANONYMOUS FUNCTIONS... 1 Using Anonymous Functions with Arrays... 4
Contents ANONYMOUS FUNCTIONS... 1 Using Anonymous Functions with Arrays... 4 ANONYMOUS FUNCTIONS Anonymous functions are a simple and concise way to define a function that contains only a single executable
More informationMatlab for Engineers
Matlab for Engineers Alistair Johnson 31st May 2012 Centre for Doctoral Training in Healthcare Innovation Institute of Biomedical Engineering Department of Engineering Science University of Oxford Supported
More informationMATLAB Laboratory 09/23/10 Lecture. Chapters 5 and 9: Plotting
MATLAB Laboratory 09/23/10 Lecture Chapters 5 and 9: Plotting Lisa A. Oberbroeckling Loyola University Maryland loberbroeckling@loyola.edu L. Oberbroeckling (Loyola University) MATLAB 09/23/10 Lecture
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 information1 >> Lecture 3 2 >> 3 >> -- Functions 4 >> Zheng-Liang Lu 172 / 225
1 >> Lecture 3 2 >> 3 >> -- Functions 4 >> Zheng-Liang Lu 172 / 225 Functions The first thing of the design of algorithms is to divide and conquer. A large and complex problem would be solved by couples
More informationStokes 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 informationComputational 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 informationQuestion Points Score Total 100
Name Signature General instructions: You may not ask questions during the test. If you believe that there is something wrong with a question, write down what you think the question is trying to ask and
More informationDr Richard Greenaway
SCHOOL OF PHYSICS, ASTRONOMY & MATHEMATICS 4PAM1008 MATLAB 4 Visualising Data Dr Richard Greenaway 4 Visualising Data 4.1 Simple Data Plotting You should now be familiar with the plot function which is
More informationELEC4042 Signal Processing 2 MATLAB Review (prepared by A/Prof Ambikairajah)
Introduction ELEC4042 Signal Processing 2 MATLAB Review (prepared by A/Prof Ambikairajah) MATLAB is a powerful mathematical language that is used in most engineering companies today. Its strength lies
More informationGetting started with MATLAB
Getting started with MATLAB You can work through this tutorial in the computer classes over the first 2 weeks, or in your own time. The Farber and Goldfarb computer classrooms have working Matlab, but
More information22-Functions Part 1 text: Chapter ECEGR 101 Engineering Problem Solving with Matlab Professor Henry Louie
22-Functions Part 1 text: Chapter 7.1-7.5 ECEGR 101 Engineering Problem Solving with Matlab Professor Henry Louie Overview Function Syntax Help Line Saving Functions Using Functions Dr. Henry Louie 2 Function
More informationTopic 2b Building Geometries into Data Arrays
Course Instructor Dr. Raymond C. Rumpf Office: A 337 Phone: (915) 747 6958 E Mail: rcrumpf@utep.edu Topic 2b Building Geometries into Data Arrays EE 4386/5301 Computational Methods in EE Outline Visualizing
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 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 informationLECTURE 1. What Is Matlab? Matlab Windows. Help
LECTURE 1 What Is Matlab? Matlab ("MATrix LABoratory") is a software package (and accompanying programming language) that simplifies many operations in numerical methods, matrix manipulation/linear algebra,
More informationLecture 2: Variables, Vectors and Matrices in MATLAB
Lecture 2: Variables, Vectors and Matrices in MATLAB Dr. Mohammed Hawa Electrical Engineering Department University of Jordan EE201: Computer Applications. See Textbook Chapter 1 and Chapter 2. Variables
More informationColorado State University Department of Mechanical Engineering. MECH Laboratory Exercise #1 Introduction to MATLAB
Colorado State University Department of Mechanical Engineering MECH 417 - Laboratory Exercise #1 Introduction to MATLAB Contents 1) Vectors and Matrices... 2 2) Polynomials... 3 3) Plotting and Printing...
More informationMATLAB Second Seminar
MATLAB Second Seminar Previous lesson Last lesson We learnt how to: Interact with MATLAB in the MATLAB command window by typing commands at the command prompt. Define and use variables. Plot graphs It
More informationAn Introduction to Numerical Methods
An Introduction to Numerical Methods Using MATLAB Khyruddin Akbar Ansari, Ph.D., P.E. Bonni Dichone, Ph.D. SDC P U B L I C AT I O N S Better Textbooks. Lower Prices. www.sdcpublications.com Powered by
More informationGetting 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 informationIntroduction to MATLAB 7 for Engineers
PowerPoint to accompany Introduction to MATLAB 7 for Engineers William J. Palm III Chapter 2 Numeric, Cell, and Structure Arrays Copyright 2005. The McGraw-Hill Companies, Inc. Permission required for
More information10 M-File Programming
MATLAB Programming: A Quick Start Files that contain MATLAB language code are called M-files. M-files can be functions that accept arguments and produce output, or they can be scripts that execute a series
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 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 informationECE 102 Engineering Computation
ECE 102 Engineering Computation Phillip Wong MATLAB Function Files Nested Functions Subfunctions Inline Functions Anonymous Functions Function Files A basic function file contains one or more function
More informationIntroductory MATLAB. Appendix A A.1 BACKGROUND A.2 STARTING WITH MATLAB. Core Topics
Appendix A Introductory MATLAB Core Topics Starting with MATLAB (A.2). Arrays (A.3). Mathematical operations with arrays (A.4). Script files (A.5). User-defined functions and function files (A.7). Anonymous
More informationINTRODUCTION TO MATLAB, SIMULINK, AND THE COMMUNICATION TOOLBOX
INTRODUCTION TO MATLAB, SIMULINK, AND THE COMMUNICATION TOOLBOX 1) Objective The objective of this lab is to review how to access Matlab, Simulink, and the Communications Toolbox, and to become familiar
More informationComputational 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 informationIntroduction to MATLAB
Introduction to MATLAB Chen Huang Computer Science and Engineering SUNY at Buffalo What is MATLAB? MATLAB (stands for matrix laboratory ) It is a language and an environment for technical computing Designed
More informationMATLAB - FUNCTIONS. Functions can accept more than one input arguments and may return more than one output arguments.
MATLAB - FUNCTIONS http://www.tutorialspoint.com/matlab/matlab_functions.htm Copyright tutorialspoint.com A function is a group of statements that together perform a task. In MATLAB, functions are defined
More informationDepartment of Chemical Engineering ChE-101: Approaches to Chemical Engineering Problem Solving MATLAB Tutorial Vb
Department of Chemical Engineering ChE-101: Approaches to Chemical Engineering Problem Solving MATLAB Tutorial Vb Making Plots with Matlab (last updated 5/29/05 by GGB) Objectives: These tutorials are
More informationBuilding Geometries in Data Arrays
EE 5303 Electromagnetic Analysis Using Finite Difference Time Domain Lecture #3 Building Geometries in Data Arrays Lecture 3 Slide 1 Lecture Outline MATLAB Data and Arrays 3D 2D 1D Building Geometries
More informationEGR 111 Introduction to MATLAB
EGR 111 Introduction to MATLAB This lab introduces the MATLAB help facility, shows how MATLAB TM, which stands for MATrix LABoratory, can be used as an advanced calculator. This lab also introduces assignment
More informationCITS2401 Computer Analysis & Visualisation
FACULTY OF ENGINEERING, COMPUTING AND MATHEMATICS CITS2401 Computer Analysis & Visualisation SCHOOL OF COMPUTER SCIENCE AND SOFTWARE ENGINEERING Topic 4 Matlab functions Material from MATLAB for Engineers,
More informationMATH (CRN 13695) Lab 1: Basics for Linear Algebra and Matlab
MATH 495.3 (CRN 13695) Lab 1: Basics for Linear Algebra and Matlab Below is a screen similar to what you should see when you open Matlab. The command window is the large box to the right containing the
More 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 informationGeorge Mason University ECE 201: Introduction to Signal Analysis Spring 2017
Assigned: January 27, 2017 Due Date: Week of February 6, 2017 George Mason University ECE 201: Introduction to Signal Analysis Spring 2017 Laboratory Project #1 Due Date Your lab report must be submitted
More informationFondamenti di Informatica
Fondamenti di Informatica Data abstraction: Vectors Prof. Emiliano Casalicchio http://www.ce.uniroma2.it/courses/foi/ Objectives This lecture discusses the basic calculations involving rectangular collections
More informationOUTLINES. 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 informationAMS 27L LAB #2 Winter 2009
AMS 27L LAB #2 Winter 2009 Plots and Matrix Algebra in MATLAB Objectives: 1. To practice basic display methods 2. To learn how to program loops 3. To learn how to write m-files 1 Vectors Matlab handles
More 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 informationScientific Computing with MATLAB
Scientific Computing with MATLAB Dra. K.-Y. Daisy Fan Department of Computer Science Cornell University Ithaca, NY, USA UNAM IIM 2012 2 Focus on computing using MATLAB Computer Science Computational Science
More informationIdentity Matrix: >> eye(3) ans = Matrix of Ones: >> ones(2,3) ans =
Very Basic MATLAB Peter J. Olver January, 2009 Matrices: Type your matrix as follows: Use space or, to separate entries, and ; or return after each row. >> [;5 0-3 6;; - 5 ] or >> [,5,6,-9;5,0,-3,6;7,8,5,0;-,,5,]
More informationMATLAB Lesson I. Chiara Lelli. October 2, Politecnico di Milano
MATLAB Lesson I Chiara Lelli Politecnico di Milano October 2, 2012 MATLAB MATLAB (MATrix LABoratory) is an interactive software system for: scientific computing statistical analysis vector and matrix computations
More 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 informationHW 4 HINTS. 1. Chapter 6
HW 4 HINTS 1. Chapter 6 ***IMPORTANT GENERAL GUIDELINE*** When running commands inside loops and conditional statements, in general ALL output should be suppressed by placing a semicolon at the of the
More informationFUNCTIONS ( WEEK 5 ) DR. USMAN ULLAH SHEIKH DR. MUSA MOHD MOKJI DR. MICHAEL TAN LONG PENG DR. AMIRJAN NAWABJAN DR. MOHD ADIB SARIJARI
FUNCTIONS SKEE1022 SCIENTIFIC PROGRAMMING ( WEEK 5 ) DR. USMAN ULLAH SHEIKH DR. MUSA MOHD MOKJI DR. MICHAEL TAN LONG PENG DR. AMIRJAN NAWABJAN DR. MOHD ADIB SARIJARI OBJECTIVES Create Function 1) Create
More informationChapter 6: User defined functions and function files
The Islamic University of Gaza Faculty of Engineering Civil Engineering Department Computer Programming (ECIV 2302) Chapter 6: User defined functions and function files ١ 6.1 Creating a function file Input
More informationIntroduction to MATLAB for Engineers, Third Edition
PowerPoint to accompany Introduction to MATLAB for Engineers, Third Edition William J. Palm III Chapter 2 Numeric, Cell, and Structure Arrays Copyright 2010. The McGraw-Hill Companies, Inc. This work is
More informationBasic Unix and Matlab Logging in from another Unix machine, e.g. ECS lab Dells
Basic Unix and Matlab 101 1 Logging in from another Unix machine, e.g. ECS lab Dells The computer we will be using for our assignments is called malkhut.engr.umbc.edu which is a Unix/Linux machine that
More informationMatlab Tutorial. The value assigned to a variable can be checked by simply typing in the variable name:
1 Matlab Tutorial 1- What is Matlab? Matlab is a powerful tool for almost any kind of mathematical application. It enables one to develop programs with a high degree of functionality. The user can write
More informationComputational Photonics, Seminar 01 on Introduction into MATLAB, Page 1
Computational Photonics, Seminar 0 on Introduction into MATLAB,.04.06 Page Introduction to MATLAB Operations on scalar variables >> a=6 6 Pay attention to the response from the workspace >> b= b = >> a+b
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 informationEL2310 Scientific Programming
Lecture 4: Programming in Matlab Yasemin Bekiroglu (yaseminb@kth.se) Florian Pokorny(fpokorny@kth.se) Overview Overview Lecture 4: Programming in Matlab Wrap Up More on Scripts and Functions Wrap Up Last
More informationMatlab notes Matlab is a matrix-based, high-performance language for technical computing It integrates computation, visualisation and programming usin
Matlab notes Matlab is a matrix-based, high-performance language for technical computing It integrates computation, visualisation and programming using familiar mathematical notation The name Matlab stands
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 informationIntroduction to Matlab
Introduction to Matlab This tour introduces the basic notions of programming with Matlab. Contents M-file scripts M-file functions Inline functions Loops Conditionals References M-file scripts A script
More informationMATLAB. MATLAB Review. MATLAB Basics: Variables. MATLAB Basics: Variables. MATLAB Basics: Subarrays. MATLAB Basics: Subarrays
MATLAB MATLAB Review Selim Aksoy Bilkent University Department of Computer Engineering saksoy@cs.bilkent.edu.tr MATLAB Basics Top-down Program Design, Relational and Logical Operators Branches and Loops
More informationWhat is Matlab? The command line Variables Operators Functions
What is Matlab? The command line Variables Operators Functions Vectors Matrices Control Structures Programming in Matlab Graphics and Plotting A numerical computing environment Simple and effective programming
More informationLecture 4 MATLAB programming (2) Dr.Qi Ying
Lecture 4 MATLAB programming (2) Dr.Qi Ying Objectives For loops While loops Loop speed-up Dot operator Array mask The For Loop The for loop is a loop that executes a block of statements for a specified
More informationBasic Simulation Lab with MATLAB
Chapter 3: Generation of Signals and Sequences 1. t = 0 : 0.001 : 1; Generate a vector of 1001 samples for t with a value between 0 & 1 with an increment of 0.001 2. y = 0.5 * t; Generate a linear ramp
More informationNumerical 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 informationIntroduction to MATLAB
Introduction to MATLAB The Desktop When you start MATLAB, the desktop appears, containing tools (graphical user interfaces) for managing files, variables, and applications associated with MATLAB. The following
More informationMATLAB TUTORIAL WORKSHEET
MATLAB TUTORIAL WORKSHEET What is MATLAB? Software package used for computation High-level programming language with easy to use interactive environment Access MATLAB at Tufts here: https://it.tufts.edu/sw-matlabstudent
More informationPhysics 326G Winter Class 2. In this class you will learn how to define and work with arrays or vectors.
Physics 326G Winter 2008 Class 2 In this class you will learn how to define and work with arrays or vectors. Matlab is designed to work with arrays. An array is a list of numbers (or other things) arranged
More informationProgramming in MATLAB
trevor.spiteri@um.edu.mt http://staff.um.edu.mt/trevor.spiteri Department of Communications and Computer Engineering Faculty of Information and Communication Technology University of Malta 17 February,
More informationMatlab Advanced Programming. Matt Wyant University of Washington
Matlab Advanced Programming Matt Wyant University of Washington Matlab as a programming Language Strengths (as compared to C/C++/Fortran) Fast to write -no type declarations needed Memory allocation/deallocation
More informationChBE 354 Useful MATLAB Functions
ChBE 354 Useful MATLAB Functions Assignment Statements a = 10 Stores 10 in a a = solve Hf HxL - f HzL, zl solves the equation for z and stores it in a a = single H143 ê 91L returns a single precision decimal
More informationMATLAB 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