{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Lecture6

Lecture6 - Lecture 6 More on Functions in MATLAB Department...

This preview shows pages 1–6. Sign up to view the full content.

Lecture 6: More on Functions in MATLAB Department of Mathematics University of California, Berkeley Math 98 Introduction to MATLAB programming

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Announcements HW1 Solutions are up http://math.berkeley.edu/ cinnawu/HW2sol.m. HW3 is posted http://math.berkeley.edu/ cinnawu/HW3.pdf.
A few Important concepts from computer science. .. Today We will focus on calling functions indirectly (in MATLAB) using function handles.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
functions and function handle Recall cube.m function Y= cube(X) Y = X 3; evaluate this function (as if we actually typed in cube(4)) >>feval(’cube’,4 ) >>ans = 64 Make an inline function >>f=inline(’x 3’ ) >>f = Inline function: f(x)=x 3 Use the @ command >>[email protected](x)(’x 3’ ) >>f [email protected](x)x 3
functions and function handle (continued) Use the @ command >>f Use a function handle >>funStr=’cube’; >>cubeFun=str2Func(cube) >> cubeFun(9) >> ans=729 What a function handles is An internal MATLAB data type, which can be used to call a function. For example, cubeFun is able to call the function cube .

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 9

Lecture6 - Lecture 6 More on Functions in MATLAB Department...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online