SUNY Geneseo Department of Mathematics
Wednesday, February 3
Math 230 02
Spring 2016
Prof. Doug Baldwin
function output = name( input1, input2, … )
statements
end
function [ avg ] = average( n )
% average computes the average of n and 2n
% Algorithm: add n + 2n
% divide by 2
avg = ( n + 2*n ) / 2;
end
>> average( 2 )
ans =
3
>> average(1)
ans =
1.5000
>> average(117)
ans =
175.5000