Chapter5-2c - (Cont Optional Arguments nargin actual input...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
User Defined Functions (Con’t)
Background image of page 1

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

View Full DocumentRight Arrow Icon
nargin - actual input arguments in calling program nargout - actual output arguments in calling program nargchk() - returns standard error message if too many/few arguments (input or output) error() - displays error message if fatal error warning() - displays warning message if non-fatal error Optional Arguments
Background image of page 2
Example of Optional Arguments (I) function [mag angle] = polar_value(x, y) %POLAR_VALUE Converts (x,y) to (mag, angle) % Function POLAR_VALUE converts an input(x,y) % value into (mag, angle), with angle in degrees. % It illustrates the use of optional arguments % (in functions). % Check for legal number of arguments error_msg = nargchk(1,2,nargin); error(error_msg); % Must be in an m-file  named polar_value.m
Background image of page 3

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

View Full DocumentRight Arrow Icon
Example of Optional Arguments (II) % Check if the y argument is missing. If so, set to 0 if nargin == 1     y = 0; end % % Check if both x AND y are 0
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 09/13/2010 for the course EGR EGR115 taught by Professor Newman during the Spring '10 term at Embry-Riddle FL/AZ.

Page1 / 12

Chapter5-2c - (Cont Optional Arguments nargin actual input...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online