-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathnewfunction.m
62 lines (56 loc) · 1.01 KB
/
newfunction.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
function varargout=newfunction(a,b,c,d)
% [aa,bb,dd,ee]=NEWFUNCTION(a,b,c,d)
%
% INPUT:
%
% a First thing - a scalar
% b Second thing - a string
% c Third thing - a scalar
% d Fourth thing - a scalar
%
% OUTPUT:
%
% aa First thing
% bb Second thing
% cc Third thing
% ee Fourth thing
%
% SEE ALSO:
%
% ANATOMY, EVER
%
% Last modified by fjsimons-at-alum.mit.edu, 07/27/2009
% FIRST PART: Always 'the same'
% Define defaults
defval('a',9.81)
defval('b','bla')
defval('c',1)
defval('d',2)
defval('fnpl',sprintf('defaultfilename_%s_%i',b,round(c)))
% SECOND PART: The algorithm
% Peform the computation
aa=a+c;
bb=c+d;
cc=a+d;
switch b
case 'bla'
dd=sprintf('I am making something with %s',b);
otherwise
dd='I was expecting bla';
end
disp(dd)
if nargout>3
ee=12;
else
ee=NaN;
end
% For loop
for in=1:4
disp(sprintf('Hello for the %ith time',in))
end
% Save a file
save(fnpl,'a','aa','bb','cc')
% THIRD PART: Always 'the same'
% Produce desired output
varns={aa,bb,cc,ee};
varargout=varns(1:nargout);