Math 98 - Introduction to MATLAB Programming. Spring Lecture 3
|
|
- Gladys Skinner
- 6 years ago
- Views:
Transcription
1
2 Reminders Instructor: Chris Policastro Class Website: Assignment Submission: Homework 2 1 Due September 8th by 11:59pm on bcourses. 2 See assignment description for hints. 3 You are encouraged to collaborate. Use the discussion page on bcourses.
3 Exercise Remember the formula for the sum of n consecutive numbers n = We want to compute this number four ways n(n + 1) 2 1 Use the MATLAB function sum. Recall that we studied sum in lecture 2. 2 Set S=0. Use a for loop to redene S at each iteration. Compare to problem about tiling a disk in lecture 2. 3 Set S=0. Use a while loop to redene S at each step. Remember to update the number counting iterations. 4 Write a function called ConSum such that ConSum(n) equals 1 n(n + 1). 2.
4 Lecture 3: Using functions to package code 1 Problems (problem_3_1) Approximating square root (Chapter 5.1 van Loan) (problem_3_2) Transition matrices (Chapter 7.1 van Loan) 2 Concepts functions, local variables matrices, matrix operations
5 (problem_3_1) Approximating square root Let A be a positive number. Think of A as the area of a square with side length A. We can construct a rectangle with side lengths L and W that has area A. This means A = L W If L W, then A L W This gives an approximation to the number A. Let us start with some L and W. Let us bring them nearer in value through averaging.
6 (problem_3_1) Approximating square root We want to write a program to implement the following steps 1 If A = 0, then output 0. 2 Otherwise, start with L = A and W = 1. 3 Replace L by the average (L + W )/2 4 Replace W by W/ 1 2 (L + W ) 5 Repeat until L W is less than a tolerance Tol 6 Output L Here Tol is a small number reecting the accuracy of the approximation. Small tolerance implies good accuracy. We do not know how many times we must repeat the steps. Therefore we should use a while loop. While L-W >= Tol, we can repeat the steps.
7 Functions Remember the following terms 1 code: a statement to be executed by the computer. For example, a conditional statement. The code implements a procedure. 2 program: a collection of codes 3 debug: to remove errors from a program 4 script: a le containing a program. We run a script. For example, run problem_1_1.m. A function packages code. However, it is dierent from a script. function: a le containing a program. We call a function. For example, CalcCents(100). Note the le name is CalcCents.m.
8 Functions We have functions in addition to scripts because functions are 1 reusable A function replaces a repeated block of code in a program 2 simplifying A function organizes groups of code within a program. A function can be written in a separate le with its own variables. 3 changeable If procedures are packaged as a function, then they are easily accessed. Helpful for code that must be modied by user or programmer.
9 Functions The format for functions is 1 %%%Name.m%%% 2 f u n c t i o n [ o utput ] = Name( i n p u t ) 3 4 Code 5 6 end The name of the function should match the name of the M-le. Use a capital letter in le name to avoid conict with built-in MATLAB functions
10 Functions Remember that MATLAB has a built-in function for computing square root. It is sqrt. 1 %%% S q r t.m %%% 2 % Computes s q u a r e r o o t o f a number u s i n g MATLAB f u n c t i o n s q r t 3 % I n p u t : a p o s i t i v e number 4 % Output : t h e s q u a r e r o o t 5 % Example : S q r t ( 4 ) w i l l y i e l d f u n c t i o n [ outputnumber ] = S q r t ( inputnumber ) 8 9 outputnumber=s q r t ( inputnumber ) ; end
11 nargin The command nargin appears within the code for a function. It is the number of inputs specied by the user. 1 %%% S q r t.m %%% 2 % Computes s q u a r e r o o t o f a number u s i n g MATLAB f u n c t i o n s q r t 3 % I n p u t : a p o s i t i v e number 4 % Output : t h e s q u a r e r o o t 5 % Example : S q r t ( 4 ) w i l l y i e l d f u n c t i o n [ outputnumber, x ] = S q r t ( inputnumber ) 8 x=n a r g i n ; 9 outputnumber=s q r t ( inputnumber ) ; 10 end
12 Testing Inputs We cannot assume that the user has correctly entered input. If the user enters incorrect input, then the function cannot be called. This makes it seem that there is an error in the function. You must add comments in the le that explain the proper format for inputs. You should include an example in the comments. Type help filename.m to display comments in command window. Compare to help for built in MATLAB function. Checking that the input has the proper format can avoid an error caused by the user.
13 return The command return halts execution of a program. The user returns to the command window. 1 %%% S q r t.m %%% 2 % Computes s q u a r e r o o t o f a number u s i n g MATLAB f u n c t i o n s q r t 3 % I n p u t : a p o s i t i v e number 4 % Output : t h e s q u a r e r o o t 5 % Example : S q r t ( 4 ) w i l l y i e l d f u n c t i o n [ outputnumber ] = S q r t ( inputnumber ) 8 i f ( n a r g i n ~= 1) 9 f p r i n t f ( ' Read comments! ' ) ; 10 r e t u r n 11 e l s e 12 outputnumber=s q r t ( inputnumber ) ; 13 end 14 end
14 Variables in Functions 1 %%%DoubleSum.m%%% 2 f u n c t i o n [ z, V a r i a b l e s ]=DoubleSum ( x, y ) 3 V a r i a b l e s =[ e x i s t ( ' x ' ) ] ; 4 5 f u n c t i o n t=add ( r, s ) 6 t=r+s ; 7 end 8 9 V a r i a b l e s =[ V a r i a b l e s, e x i s t ( ' r ' ) ] ; 10 V a r i a b l e s =[ V a r i a b l e s, e x i s t ( ' t ' ) ] ; z =2 (Add ( x, y ) ) ; V a r i a b l e s =[ V a r i a b l e s, e x i s t ( ' r ' ) ] ; 15 V a r i a b l e s =[ V a r i a b l e s, e x i s t ( ' t ' ) ] ; 16 end Can you call the subfunction in lines 5-7 called Add?
15 Variables in Functions Remember that the Workspace is a special le called a MAT-le which contains the variables we have dened during our MATLAB session. MATLAB must allocate memory to call a function. Think of a function as having its own Workspace. MATLAB takes the following steps 1 We enter input to execute the function. MATLAB creates a MAT-le. 2 MATLAB goes through the code. Each time a variable is dened, the variable is saved in the MAT-le. 3 MATLAB will not look other places for variable. It will not look in the WorkSpace. Suppose the code species x=7. Suppose we have x= in the Workspace. There will not be an error. 4 After going through the code, MATLAB has the numbers generated by the program.matlab saves the numbers to the output variables specied by the user. These appear in the Workspace. 5 The MAT-le is deleted.
16 Variables in Functions This means that 1 Variables in functions are not global Variables in a function cannot be accessed or modied by other functions. Therefore variables within a function cannot conict with variables of the same name outside the function. 2 Variables in functions do not persist When the code in a function nishes execution, the values assigned to variables are not stored in the Workspace. See lecture 4 for more information on the scope of variables in functions.
17 Review of problem_3_1 The debugger is a tool to help locate errors in a code. Click the dash next to lines 9 of problem_3_1.m. A red dot will appear next to the line. It is called a break point Calling problem_3_1 will prompt the debugger.
18 Review of problem_3_1 We want to see how variables are stored during the execution of the program in problem_3_1. Try x = problem_3_1(8,1e-4). Remember that this is scientic notation for Use the command dbstep to go line by line through the code. 2 Use dbstack to check your spot in the code. This will tell you the function being called. 3 Exit using dbquit. 4 Click on the red dot to make it disappear.
19 (exercise_3_1) Consider the following version of IsMagic.m the program from homework assignment 1. 1 i n p u t M a t r i x=i n p u t ( ' E n t e r a m a t r i x : ' ) ; 2 3 % sum o f t h e columns, rows, and d i a g o n a l s o f t h e i n p u t m a t r i x 4 sumcol = sum ( i n p u t M a t r i x ) ; 5 sumrow = sum ( t r a n s ( i n p u t M a t r i x ) ) ; 6 sumdiag1 = t r a c e ( i n p u t M a t r i x ) 7 sumdiag2 = t r a c e ( f l i p u d ( i n p u t M a t r i x ) ) ; 8 9 % Set r e s u l t = 1 i f a l l t h e sums a r e e q u a l. Otherwise, s e t r e s u l t = r e s u l t = i s e q u a l ( sumcol, sumrow ', sumdiag1 ones ( 1, n ), sumdiag2 ones ( 1, n ) ) ; r e t u r n
20 (exercise_3_1) Try to make the following improvement. 1 Turn into a function 2 Use debugger to locate errors 3 Improve comments 4 Check user input Use [m,n] = size(inputmatrix) to calculate the number of rows (m) and number of columns. Check m == n Check m >= 3 Use all to check that all entries are nonzero. Can you check that all entries are positive? Use Vector=inputMatrix(:)' to create a row vector. Consider the vector Vector01=(Vector > 0) If the user does not specify a matrix, then set the default input to be magic(4).
21 (problem_3_2) Transition matrices Let Let x be a 4 1 column vec P = x 1 x = x 2 x 3 x 4
22 (problem_3_2) Transition matrices Think of the entries of x as corresponding to four possible states of a system. Each state has a probability of occuring. x i is the probability of the system being in the ith state. For example x 1 = 0.4 means there is a 40% chance of the system being in state 1 Think of the (i, j)th entry of P as being the probability of transitioning from state j to state i during one step of a process. We call P a transition matrix because y = P x is the probability of the states after one step of the process.
23 (problem_3_2) Transition matrices We want to write a function called problem_3_2 such that 1 the function has two inputs P an n n matrix x an n 1 vector 2 the function outputs y = P x
24 Review of problem_3_2 The function problem_3_2 helps us study the likelihood of states of the system. In particular, we would like to study the probabilities as the process goes on for a long time. This means that we want to calculate P N x for N a large number. This kind of process is called a Markov process. See Chapter 7.1 of van Loan for more information on matrices and matrix operations.
25 (exercise_3_2) Take P to be P = We want to nd x such that x = P x. The probabilities of the system being in states 1,2,3,4 does not change during the process. Use the command [Vect,Val]=eig(P) to return a 4 4 matrix Vect and a 4 4 matrix Val. Note that the columns of Vect are eigenvectors of P. Note Val is a diagonal matrix consisting of eigenvalues. More precisely is approximately zero. What eigenvector are we looking for? P Vect - Vect Val
Lecture 4: Matrices. Math 98, Spring Math 98, Spring 2018 Lecture 4: Matrices 1 / 20
Lecture 4: Matrices Math 98, Spring 2018 Math 98, Spring 2018 Lecture 4: Matrices 1 / 20 Reminders Instructor: Eric Hallman Login:!cmfmath98 Password: c@1analog Class Website: https://math.berkeley.edu/~ehallman/98-fa18/
More informationLecture 10: Powers of Matrices, Difference Equations
Lecture 10: Powers of Matrices, Difference Equations Difference Equations A difference equation, also sometimes called a recurrence equation is an equation that defines a sequence recursively, i.e. each
More informationMAT 1302B Mathematical Methods II
MAT 1302B Mathematical Methods II Alistair Savage Mathematics and Statistics University of Ottawa Winter 2015 Lecture 19 Alistair Savage (uottawa) MAT 1302B Mathematical Methods II Winter 2015 Lecture
More informationCSCE 155N Fall Homework Assignment 2: Stress-Strain Curve. Assigned: September 11, 2012 Due: October 02, 2012
CSCE 155N Fall 2012 Homework Assignment 2: Stress-Strain Curve Assigned: September 11, 2012 Due: October 02, 2012 Note: This assignment is to be completed individually - collaboration is strictly prohibited.
More informationMATLAB BASICS. Instructor: Prof. Shahrouk Ahmadi. TA: Kartik Bulusu
MATLAB BASICS Instructor: Prof. Shahrouk Ahmadi 1. What are M-files TA: Kartik Bulusu M-files are files that contain a collection of MATLAB commands or are used to define new MATLAB functions. For the
More informationMatrix-Vector Operations
Week3 Matrix-Vector Operations 31 Opening Remarks 311 Timmy Two Space View at edx Homework 3111 Click on the below link to open a browser window with the Timmy Two Space exercise This exercise was suggested
More informationMatrix-Vector Operations
Week3 Matrix-Vector Operations 31 Opening Remarks 311 Timmy Two Space View at edx Homework 3111 Click on the below link to open a browser window with the Timmy Two Space exercise This exercise was suggested
More information22A-2 SUMMER 2014 LECTURE Agenda
22A-2 SUMMER 204 LECTURE 2 NATHANIEL GALLUP The Dot Product Continued Matrices Group Work Vectors and Linear Equations Agenda 2 Dot Product Continued Angles between vectors Given two 2-dimensional vectors
More informationExample Example Example Example
7. More Practice with Iteration and Conditionals Through Graphics We will Draw Pictures Using Three User-Defined* Graphics Functions For-Loop Problems Introduce While-Loops DrawRect DrawDisk DrawStar Rectangles
More information1 Overview of Simulink. 2 State-space equations
Modelling and simulation of engineering systems Simulink Exercise 1 - translational mechanical systems Dr. M. Turner (mct6@sun.engg.le.ac.uk 1 Overview of Simulink Simulink is a package which runs in the
More informationMath Assignment 3 - Linear Algebra
Math 216 - Assignment 3 - Linear Algebra Due: Tuesday, March 27. Nothing accepted after Thursday, March 29. This is worth 15 points. 10% points off for being late. You may work by yourself or in pairs.
More informationCOMS 6100 Class Notes
COMS 6100 Class Notes Daniel Solus September 20, 2016 1 General Remarks The Lecture notes submitted by the class have been very good. Integer division seemed to be a common oversight when working the Fortran
More informationWILEY. Differential Equations with MATLAB (Third Edition) Brian R. Hunt Ronald L. Lipsman John E. Osborn Jonathan M. Rosenberg
Differential Equations with MATLAB (Third Edition) Updated for MATLAB 2011b (7.13), Simulink 7.8, and Symbolic Math Toolbox 5.7 Brian R. Hunt Ronald L. Lipsman John E. Osborn Jonathan M. Rosenberg All
More informationCS Homework 3. October 15, 2009
CS 294 - Homework 3 October 15, 2009 If you have questions, contact Alexandre Bouchard (bouchard@cs.berkeley.edu) for part 1 and Alex Simma (asimma@eecs.berkeley.edu) for part 2. Also check the class website
More informationA First Course on Kinetics and Reaction Engineering Example S3.1
Example S3.1 Problem Purpose This example shows how to use the MATLAB script file, FitLinSR.m, to fit a linear model to experimental data. Problem Statement Assume that in the course of solving a kinetics
More informationNote: The command name is upper case in the description given by help, but must be lower case in actual use. And the backslash Anb is dierent when A i
MATLAB Tutorial You need a small number of basic commands to start using MATLAB. This short tutorial describes those fundamental commands. You need to create vectors and matrices, to change them, and to
More informationIntroduction to Matlab
History of Matlab Starting Matlab Matrix operation Introduction to Matlab Useful commands in linear algebra Scripts-M file Use Matlab to explore the notion of span and the geometry of eigenvalues and eigenvectors.
More informationMatlab Exercise 0 Due 1/25/06
Matlab Exercise 0 Due 1/25/06 Geop 523 Theoretical Seismology January 18, 2006 Much of our work in this class will be done using Matlab. The goal of this exercise is to get you familiar with using Matlab
More informationMath Camp Notes: Linear Algebra II
Math Camp Notes: Linear Algebra II Eigenvalues Let A be a square matrix. An eigenvalue is a number λ which when subtracted from the diagonal elements of the matrix A creates a singular matrix. In other
More informationFinite Math - J-term Section Systems of Linear Equations in Two Variables Example 1. Solve the system
Finite Math - J-term 07 Lecture Notes - //07 Homework Section 4. - 9, 0, 5, 6, 9, 0,, 4, 6, 0, 50, 5, 54, 55, 56, 6, 65 Section 4. - Systems of Linear Equations in Two Variables Example. Solve the system
More informationIntroduction to Computational Neuroscience
CSE2330 Introduction to Computational Neuroscience Basic computational tools and concepts Tutorial 1 Duration: two weeks 1.1 About this tutorial The objective of this tutorial is to introduce you to: the
More information(t) ), ( ) where t is time, T is the reaction time, u n is the position of the nth car, and the "sensitivity coefficient" λ may depend on un 1(
Page 1 A Model of Traffic Flow Everyone has had the experience of sitting in a traffic jam, or of seeing cars bunch up on a road for no apparent good reason MATLAB and SIMULINK are good tools for studying
More informationThis appendix provides a very basic introduction to linear algebra concepts.
APPENDIX Basic Linear Algebra Concepts This appendix provides a very basic introduction to linear algebra concepts. Some of these concepts are intentionally presented here in a somewhat simplified (not
More informationMOL410/510 Problem Set 1 - Linear Algebra - Due Friday Sept. 30
MOL40/50 Problem Set - Linear Algebra - Due Friday Sept. 30 Use lab notes to help solve these problems. Problems marked MUST DO are required for full credit. For the remainder of the problems, do as many
More informationSection 4.1 The Power Method
Section 4.1 The Power Method Key terms Dominant eigenvalue Eigenpair Infinity norm and 2-norm Power Method Scaled Power Method Power Method for symmetric matrices The notation used varies a bit from that
More information1 R.V k V k 1 / I.k/ here; we ll stimulate the action potential another way.) Note that this further simplifies to. m 3 k h k.
1. The goal of this problem is to simulate a propagating action potential for the Hodgkin-Huxley model and to determine the propagation speed. From the class notes, the discrete version (i.e., after breaking
More informationLab 2 Worksheet. Problems. Problem 1: Geometry and Linear Equations
Lab 2 Worksheet Problems Problem : Geometry and Linear Equations Linear algebra is, first and foremost, the study of systems of linear equations. You are going to encounter linear systems frequently in
More informationMath/Phys/Engr 428, Math 529/Phys 528 Numerical Methods - Summer Homework 3 Due: Tuesday, July 3, 2018
Math/Phys/Engr 428, Math 529/Phys 528 Numerical Methods - Summer 28. (Vector and Matrix Norms) Homework 3 Due: Tuesday, July 3, 28 Show that the l vector norm satisfies the three properties (a) x for x
More informationPageRank: The Math-y Version (Or, What To Do When You Can t Tear Up Little Pieces of Paper)
PageRank: The Math-y Version (Or, What To Do When You Can t Tear Up Little Pieces of Paper) In class, we saw this graph, with each node representing people who are following each other on Twitter: Our
More informationLab 2: Static Response, Cantilevered Beam
Contents 1 Lab 2: Static Response, Cantilevered Beam 3 1.1 Objectives.......................................... 3 1.2 Scalars, Vectors and Matrices (Allen Downey)...................... 3 1.2.1 Attribution.....................................
More informationProperties of Linear Transformations from R n to R m
Properties of Linear Transformations from R n to R m MATH 322, Linear Algebra I J. Robert Buchanan Department of Mathematics Spring 2015 Topic Overview Relationship between the properties of a matrix transformation
More information22A-2 SUMMER 2014 LECTURE 5
A- SUMMER 0 LECTURE 5 NATHANIEL GALLUP Agenda Elimination to the identity matrix Inverse matrices LU factorization Elimination to the identity matrix Previously, we have used elimination to get a system
More informationOptimization and Calculus
Optimization and Calculus To begin, there is a close relationship between finding the roots to a function and optimizing a function. In the former case, we solve for x. In the latter, we solve: g(x) =
More informationAMSC/CMSC 466 Problem set 3
AMSC/CMSC 466 Problem set 3 1. Problem 1 of KC, p180, parts (a), (b) and (c). Do part (a) by hand, with and without pivoting. Use MATLAB to check your answer. Use the command A\b to get the solution, and
More informationMath 515 Fall, 2008 Homework 2, due Friday, September 26.
Math 515 Fall, 2008 Homework 2, due Friday, September 26 In this assignment you will write efficient MATLAB codes to solve least squares problems involving block structured matrices known as Kronecker
More informationDesigning Information Devices and Systems I Fall 2018 Homework 3
Last Updated: 28-9-5 :8 EECS 6A Designing Information Devices and Systems I Fall 28 Homework 3 This homework is due September 4, 28, at 23:59. Self-grades are due September 8, 28, at 23:59. Submission
More informationNumerical Linear Algebra
Math 45 David Arnold David-Arnold@Eureka.redwoods.cc.ca.us Abstract In this activity you will learn how to solve systems of linear equations using LU decomposition, with both forward and substitution.
More information4. Linear transformations as a vector space 17
4 Linear transformations as a vector space 17 d) 1 2 0 0 1 2 0 0 1 0 0 0 1 2 3 4 32 Let a linear transformation in R 2 be the reflection in the line = x 2 Find its matrix 33 For each linear transformation
More informationMATH 341 MIDTERM 2. (a) [5 pts] Demonstrate that A and B are row equivalent by providing a sequence of row operations leading from A to B.
11/01/2011 Bormashenko MATH 341 MIDTERM 2 Show your work for all the problems. Good luck! (1) Let A and B be defined as follows: 1 1 2 A =, B = 1 2 3 0 2 ] 2 1 3 4 Name: (a) 5 pts] Demonstrate that A and
More informationNumerical Linear Algebra
Introduction Numerical Linear Algebra Math 45 Linear Algebra David Arnold David-Arnold@Eureka.redwoods.cc.ca.us Abstract In this activity you will learn how to solve systems of linear equations using LU
More informationEigenvalues and Eigenvectors
Eigenvalues and Eigenvectors MAT 67L, Laboratory III Contents Instructions (1) Read this document. (2) The questions labeled Experiments are not graded, and should not be turned in. They are designed for
More informationMATH3200, Lecture 31: Applications of Eigenvectors. Markov Chains and Chemical Reaction Systems
Lecture 31: Some Applications of Eigenvectors: Markov Chains and Chemical Reaction Systems Winfried Just Department of Mathematics, Ohio University April 9 11, 2018 Review: Eigenvectors and left eigenvectors
More information= main diagonal, in the order in which their corresponding eigenvectors appear as columns of E.
3.3 Diagonalization Let A = 4. Then and are eigenvectors of A, with corresponding eigenvalues 2 and 6 respectively (check). This means 4 = 2, 4 = 6. 2 2 2 2 Thus 4 = 2 2 6 2 = 2 6 4 2 We have 4 = 2 0 0
More informationHomework 6: Image Completion using Mixture of Bernoullis
Homework 6: Image Completion using Mixture of Bernoullis Deadline: Wednesday, Nov. 21, at 11:59pm Submission: You must submit two files through MarkUs 1 : 1. a PDF file containing your writeup, titled
More informationEigenvalue and Eigenvector Homework
Eigenvalue and Eigenvector Homework Olena Bormashenko November 4, 2 For each of the matrices A below, do the following:. Find the characteristic polynomial of A, and use it to find all the eigenvalues
More informationLecture 3: Special Matrices
Lecture 3: Special Matrices Feedback of assignment1 Random matrices The magic matrix commend magic() doesn t give us random matrix. Random matrix means we will get different matrices each time when we
More informationCSCI 2033 Spring 2016 ELEMENTARY COMPUTATIONAL LINEAR ALGEBRA
CSCI 2033 Spring 2016 ELEMENTARY COMPUTATIONAL LINEAR ALGEBRA Class time : MW 4:00-5:15pm Room : Vincent Hall 16 Instructor : Yousef Saad URL : www-users.cselabs.umn.edu/classes/spring-2016 /csci2033 afternoon
More informationImage Registration Lecture 2: Vectors and Matrices
Image Registration Lecture 2: Vectors and Matrices Prof. Charlene Tsai Lecture Overview Vectors Matrices Basics Orthogonal matrices Singular Value Decomposition (SVD) 2 1 Preliminary Comments Some of this
More informationCOLUMN VECTORS a=[1;2;3] b. a(1) = first.entry of a
Lecture 2 vectors and matrices ROW VECTORS Enter the following in SciLab: [1,2,3] scilab notation for row vectors [8]==8 a=[2 3 4] separate entries with spaces or commas b=[10,10,10] a+b, b-a add, subtract
More informationExercise 1.3 Work out the probabilities that it will be cloudy/rainy the day after tomorrow.
54 Chapter Introduction 9 s Exercise 3 Work out the probabilities that it will be cloudy/rainy the day after tomorrow Exercise 5 Follow the instructions for this problem given on the class wiki For the
More informationEigenvalues and eigenvectors
Roberto s Notes on Linear Algebra Chapter 0: Eigenvalues and diagonalization Section Eigenvalues and eigenvectors What you need to know already: Basic properties of linear transformations. Linear systems
More informationMatlab Instruction Primer; Chem 691, Spring 2016
1 Matlab Instruction Primer; Chem 691, Spring 2016 This version dated February 10, 2017 CONTENTS I. Help: To obtain information about any instruction in Matlab 1 II. Scripting 1 III. Loops, determine an
More informationLecture 5b: Starting Matlab
Lecture 5b: Starting Matlab James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University August 7, 2013 Outline 1 Resources 2 Starting Matlab 3 Homework
More information3.3 Real Zeros of Polynomial Functions
71_00.qxp 12/27/06 1:25 PM Page 276 276 Chapter Polynomial and Rational Functions. Real Zeros of Polynomial Functions Long Division of Polynomials Consider the graph of f x 6x 19x 2 16x 4. Notice in Figure.2
More information[ Here 21 is the dot product of (3, 1, 2, 5) with (2, 3, 1, 2), and 31 is the dot product of
. Matrices A matrix is any rectangular array of numbers. For example 3 5 6 4 8 3 3 is 3 4 matrix, i.e. a rectangular array of numbers with three rows four columns. We usually use capital letters for matrices,
More informationHomework Assignment 4 Root Finding Algorithms The Maximum Velocity of a Car Due: Friday, February 19, 2010 at 12noon
ME 2016 A Spring Semester 2010 Computing Techniques 3-0-3 Homework Assignment 4 Root Finding Algorithms The Maximum Velocity of a Car Due: Friday, February 19, 2010 at 12noon Description and Outcomes In
More informationDesigning Information Devices and Systems I Spring 2018 Homework 5
EECS 16A Designing Information Devices and Systems I Spring 2018 Homework All problems on this homework are practice, however all concepts covered here are fair game for the exam. 1. Sports Rank Every
More informationMATLAB and Mathematical Introduction Will be discussed in class on 1/24/11
MATLAB and Mathematical Introduction Will be discussed in class on 1/24/11 GEOP 523; Theoretical Seismology January 17, 2011 Much of our work in this class will be done using MATLAB. The goal of this exercise
More informationConvex Optimization / Homework 1, due September 19
Convex Optimization 1-725/36-725 Homework 1, due September 19 Instructions: You must complete Problems 1 3 and either Problem 4 or Problem 5 (your choice between the two). When you submit the homework,
More informationDesigning Information Devices and Systems I Fall 2017 Homework 3
EECS 6A Designing Information Devices and Systems I Fall 07 Homework 3 This homework is due September 8, 07, at 3:9. Self-grades are due September, 07, at 3:9. Submission Format Your homework submission
More informationMath 552 Scientific Computing II Spring SOLUTIONS: Homework Set 1
Math 552 Scientific Computing II Spring 21 SOLUTIONS: Homework Set 1 ( ) a b 1 Let A be the 2 2 matrix A = By hand, use Gaussian elimination with back c d substitution to obtain A 1 by solving the two
More informationHomework 1 Solutions
18-9 Signals and Systems Profs. Byron Yu and Pulkit Grover Fall 18 Homework 1 Solutions Part One 1. (8 points) Consider the DT signal given by the algorithm: x[] = 1 x[1] = x[n] = x[n 1] x[n ] (a) Plot
More information2. The Power Method for Eigenvectors
2. Power Method We now describe the power method for computing the dominant eigenpair. Its extension to the inverse power method is practical for finding any eigenvalue provided that a good initial approximation
More informationModel-building and parameter estimation
Luleå University of Technology Johan Carlson Last revision: July 27, 2009 Measurement Technology and Uncertainty Analysis - E7021E MATLAB homework assignment Model-building and parameter estimation Introduction
More informationDesigning Information Devices and Systems I Fall 2018 Homework 5
Last Updated: 08-09-9 0:6 EECS 6A Designing Information Devices and Systems I Fall 08 Homework 5 This homework is due September 8, 08, at 3:59. Self-grades are due October, 08, at 3:59. Submission Format
More informationEcon Slides from Lecture 8
Econ 205 Sobel Econ 205 - Slides from Lecture 8 Joel Sobel September 1, 2010 Computational Facts 1. det AB = det BA = det A det B 2. If D is a diagonal matrix, then det D is equal to the product of its
More informationUsing Microsoft Excel
Using Microsoft Excel Objective: Students will gain familiarity with using Excel to record data, display data properly, use built-in formulae to do calculations, and plot and fit data with linear functions.
More informationNew Mexico Tech Hyd 510
Vectors vector - has magnitude and direction (e.g. velocity, specific discharge, hydraulic gradient) scalar - has magnitude only (e.g. porosity, specific yield, storage coefficient) unit vector - a unit
More informationPowerPoints organized by Dr. Michael R. Gustafson II, Duke University
Part 3 Chapter 10 LU Factorization 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 informationTOPIC 2 Computer application for manipulating matrix using MATLAB
YOGYAKARTA STATE UNIVERSITY MATHEMATICS AND NATURAL SCIENCES FACULTY MATHEMATICS EDUCATION STUDY PROGRAM TOPIC 2 Computer application for manipulating matrix using MATLAB Definition of Matrices in MATLAB
More informationNotes on singular value decomposition for Math 54. Recall that if A is a symmetric n n matrix, then A has real eigenvalues A = P DP 1 A = P DP T.
Notes on singular value decomposition for Math 54 Recall that if A is a symmetric n n matrix, then A has real eigenvalues λ 1,, λ n (possibly repeated), and R n has an orthonormal basis v 1,, v n, where
More informationMath 304 Handout: Linear algebra, graphs, and networks.
Math 30 Handout: Linear algebra, graphs, and networks. December, 006. GRAPHS AND ADJACENCY MATRICES. Definition. A graph is a collection of vertices connected by edges. A directed graph is a graph all
More informationLab 1: Dynamic Simulation Using Simulink and Matlab
Lab 1: Dynamic Simulation Using Simulink and Matlab Objectives In this lab you will learn how to use a program called Simulink to simulate dynamic systems. Simulink runs under Matlab and uses block diagrams
More informationMath 504 (Fall 2011) 1. (*) Consider the matrices
Math 504 (Fall 2011) Instructor: Emre Mengi Study Guide for Weeks 11-14 This homework concerns the following topics. Basic definitions and facts about eigenvalues and eigenvectors (Trefethen&Bau, Lecture
More information1 Linearity and Linear Systems
Mathematical Tools for Neuroscience (NEU 34) Princeton University, Spring 26 Jonathan Pillow Lecture 7-8 notes: Linear systems & SVD Linearity and Linear Systems Linear system is a kind of mapping f( x)
More informationchapter 5 INTRODUCTION TO MATRIX ALGEBRA GOALS 5.1 Basic Definitions
chapter 5 INTRODUCTION TO MATRIX ALGEBRA GOALS The purpose of this chapter is to introduce you to matrix algebra, which has many applications. You are already familiar with several algebras: elementary
More information14. Properties of the Determinant
14. Properties of the Determinant Last time we showed that the erminant of a matrix is non-zero if and only if that matrix is invertible. We also showed that the erminant is a multiplicative function,
More informationMATH 315 Linear Algebra Homework #1 Assigned: August 20, 2018
Homework #1 Assigned: August 20, 2018 Review the following subjects involving systems of equations and matrices from Calculus II. Linear systems of equations Converting systems to matrix form Pivot entry
More informationCSC 1700 Analysis of Algorithms: Warshall s and Floyd s algorithms
CSC 1700 Analysis of Algorithms: Warshall s and Floyd s algorithms Professor Henry Carter Fall 2016 Recap Space-time tradeoffs allow for faster algorithms at the cost of space complexity overhead Dynamic
More informationLAB 1: MATLAB - Introduction to Programming. Objective:
LAB 1: MATLAB - Introduction to Programming Objective: The objective of this laboratory is to review how to use MATLAB as a programming tool and to review a classic analytical solution to a steady-state
More informationImage Compression Using Singular Value Decomposition
Image Compression Using Singular Value Decomposition Ian Cooper and Craig Lorenc December 15, 2006 Abstract Singular value decomposition (SVD) is an effective tool for minimizing data storage and data
More informationSection 29: What s an Inverse?
Section 29: What s an Inverse? Our investigations in the last section showed that all of the matrix operations had an identity element. The identity element for addition is, for obvious reasons, called
More informationGaussian Elimination and Back Substitution
Jim Lambers MAT 610 Summer Session 2009-10 Lecture 4 Notes These notes correspond to Sections 31 and 32 in the text Gaussian Elimination and Back Substitution The basic idea behind methods for solving
More informationAnnouncements. Problem Set 6 due next Monday, February 25, at 12:50PM. Midterm graded, will be returned at end of lecture.
Turing Machines Hello Hello Condensed Slide Slide Readers! Readers! This This lecture lecture is is almost almost entirely entirely animations that that show show how how each each Turing Turing machine
More informationSolution Set 7, Fall '12
Solution Set 7, 18.06 Fall '12 1. Do Problem 26 from 5.1. (It might take a while but when you see it, it's easy) Solution. Let n 3, and let A be an n n matrix whose i, j entry is i + j. To show that det
More informationVECTORS AND MATRICES
VECTORS AND MATRICES COMPUTER SESSION C1 BACKGROUND PREPARATIONS The session is divided into two parts. The first part involves experimenting in the Mathematics Laboratory and the second part involves
More informationLaboratory 11 Control Systems Laboratory ECE3557. State Feedback Controller for Position Control of a Flexible Joint
Laboratory 11 State Feedback Controller for Position Control of a Flexible Joint 11.1 Objective The objective of this laboratory is to design a full state feedback controller for endpoint position control
More informationProgramming Assignment 4: Image Completion using Mixture of Bernoullis
Programming Assignment 4: Image Completion using Mixture of Bernoullis Deadline: Tuesday, April 4, at 11:59pm TA: Renie Liao (csc321ta@cs.toronto.edu) Submission: You must submit two files through MarkUs
More informationThe Principal Component Analysis
The Principal Component Analysis Philippe B. Laval KSU Fall 2017 Philippe B. Laval (KSU) PCA Fall 2017 1 / 27 Introduction Every 80 minutes, the two Landsat satellites go around the world, recording images
More informationMATRICES. a m,1 a m,n A =
MATRICES Matrices are rectangular arrays of real or complex numbers With them, we define arithmetic operations that are generalizations of those for real and complex numbers The general form a matrix of
More informationMultivariable Control Laboratory experiment 2 The Quadruple Tank 1
Multivariable Control Laboratory experiment 2 The Quadruple Tank 1 Department of Automatic Control Lund Institute of Technology 1. Introduction The aim of this laboratory exercise is to study some different
More informationClass President: A Network Approach to Popularity. Due July 18, 2014
Class President: A Network Approach to Popularity Due July 8, 24 Instructions. Due Fri, July 8 at :59 PM 2. Work in groups of up to 3 3. Type up the report, and submit as a pdf on D2L 4. Attach the code
More informationIntroduction to Hartree-Fock calculations in Spartan
EE5 in 2008 Hannes Jónsson Introduction to Hartree-Fock calculations in Spartan In this exercise, you will get to use state of the art software for carrying out calculations of wavefunctions for molecues,
More informationMath 103, Summer 2006 Determinants July 25, 2006 DETERMINANTS. 1. Some Motivation
DETERMINANTS 1. Some Motivation Today we re going to be talking about erminants. We ll see the definition in a minute, but before we get into ails I just want to give you an idea of why we care about erminants.
More informationChapter 1 Linear Equations. 1.1 Systems of Linear Equations
Chapter Linear Equations. Systems of Linear Equations A linear equation in the n variables x, x 2,..., x n is one that can be expressed in the form a x + a 2 x 2 + + a n x n = b where a, a 2,..., a n and
More informationReview of Basic Concepts in Linear Algebra
Review of Basic Concepts in Linear Algebra Grady B Wright Department of Mathematics Boise State University September 7, 2017 Math 565 Linear Algebra Review September 7, 2017 1 / 40 Numerical Linear Algebra
More informationDesigning Information Devices and Systems I Fall 2018 Lecture Notes Note Introduction to Linear Algebra the EECS Way
EECS 16A Designing Information Devices and Systems I Fall 018 Lecture Notes Note 1 1.1 Introduction to Linear Algebra the EECS Way In this note, we will teach the basics of linear algebra and relate it
More informationProblem set 1. (c) Is the Ford-Fulkerson algorithm guaranteed to produce an acyclic maximum flow?
CS261, Winter 2017. Instructor: Ashish Goel. Problem set 1 Electronic submission to Gradescope due 11:59pm Thursday 2/2. Form a group of 2-3 students that is, submit one homework with all of your names.
More informationHomework and Computer Problems for Math*2130 (W17).
Homework and Computer Problems for Math*2130 (W17). MARCUS R. GARVIE 1 December 21, 2016 1 Department of Mathematics & Statistics, University of Guelph NOTES: These questions are a bare minimum. You should
More informationEigenvalues, Eigenvectors, and Diagonalization
Week12 Eigenvalues, Eigenvectors, and Diagonalization 12.1 Opening Remarks 12.1.1 Predicting the Weather, Again Let us revisit the example from Week 4, in which we had a simple model for predicting the
More information