Jun 06, 2006 16:27
I'm posting this because I realize that I really understand how to write these scripts. I'm not boasting, I'm leaving this for the future me that will look at it and think "man, I was damned cool."
function [average] = stat2(x)
step = 1;
while step <= length(x)
if x(step) < 0;
x(step) = [];
end
step = step + 1;
end
average = 0;
sumAvg = 0;
for ind = 1:length(x)
sumAvg = sumAvg + x(ind);
end
average = sumAvg / length(x);
I wrote this fairly quickly, with not much thinking. I'm totally loving this class.