## "Fossies" - the Fresh Open Source Software Archive

### Member "FreeMat-4.2-Source/help/text/nargout.mdc" (26 Jul 2013, 1387 Bytes) of package /linux/misc/FreeMat-4.2-Source.tar.gz:

As a special service "Fossies" has tried to format the requested text file into HTML format (style:

standard) with prefixed line numbers.
Alternatively you can here

view or

download the uninterpreted source code file.

1
2 Usage
3
4 The nargout function computes the number of return values
5 requested from a function when it was called. The general
6 syntax for its use
7
8 y = nargout
9
10 FreeMat allows for fewer return values to be requested from
11 a function than were declared, and nargout can be used to
12 determine exactly what subset of the functions outputs are
13 required.
14 You can also use nargout on a function handle to return the
15 number of input arguments expected by the function
16
17 y = nargout(fun)
18
19 where fun is the name of the function (e.g. 'sin') or a
20 function handle.
21
22
23 Example
24
25 Here is a function that is declared to return five values,
26 and that simply prints the value of nargout each time it is
27 called.
28
29 nargouttest.m
30
31
32 function [a1,a2,a3,a4,a5] = nargouttest
33 printf('nargout = %d\n',nargout);
34 a1 = 1; a2 = 2; a3 = 3; a4 = 4; a5 = 5;
35
36
37 --> a1 = nargouttest
38 nargout = 1
39
40 a1 =
41 1
42
43 --> [a1,a2] = nargouttest
44 nargout = 2
45 a1 =
46 1
47
48 a2 =
49 2
50
51 --> [a1,a2,a3] = nargouttest
52 nargout = 3
53 a1 =
54 1
55
56 a2 =
57 2
58
59 a3 =
60 3
61
62 --> [a1,a2,a3,a4,a5] = nargouttest
63 nargout = 5
64 a1 =
65 1
66
67 a2 =
68 2
69
70 a3 =
71 3
72
73 a4 =
74 4
75
76 a5 =
77 5
78
79 --> nargout('sin')
80
81 ans =
82 1
83
84 --> y = @sin
85
86 y =
87 @sin
88 --> nargout(y)
89
90 ans =
91 1
92
93
94 * FreeMat_Documentation
95 * Functions_and_Scripts
96 * Generated on Thu Jul 25 2013 17:17:14 for FreeMat by
97 doxygen_ 1.8.1.1
98