using matlab, i'm to create a program that takes a set of user-input integers, then returns the largest, smallest, sum, and average. here's the catch: i can't use any built-in functions. so i can't just type in min, max, or mean.
my little programming experience has been with expanding on built-in functions, so i have no idea how REAL programming works. i assume it's some kind of loop, but i can't fathom how to create such a loop. i bet someone here will know exactly how to do this in matlab, but if you can just shed some light on how to create your own functions from scratch, that might help me understand.
Name:
Anonymous2007-04-26 0:18 ID:azZEeofA
dunno 'bout matlab specifically, but here's some pseudocode
should get you on the right track
n = (get a number)
minimum = n
maximum = n
sum = n
count = 1
loop {
n = (get another number)
sum = sum + n
count = count + 1
if n < minimum then n = minimum
if n > maximum then n = maximum
}
average = sum / count
Name:
Anonymous2007-04-26 3:30 ID:t29qmFuq
zomg MATLAB TORRENT NAO PLOX
Name:
Anonymous2007-04-26 6:11 ID:MT1nUf/o
>>2
i think i'm starting to understand. loop the user input, redefining my three outputs each time a new number is entered. sum is redefined each time a number is input, adding the new input. min is defined as the first number input, then redefined if the newest number is smaller. max works similarly. average is just sum/number of loops + 1.
that's great. simple as it is, i probably wouldn't have come up with it on my own.
Name:
Anonymous2007-04-26 6:23 ID:FW0MKUdT
silly assignment, in matlab you should use builtins for everything
Name:
Anonymous2007-04-26 6:37 ID:1l2lVO/9
>>4
What is this 'redefine' crap? Get that maths out of your head, you're in /prog/ now.
Name:
Anonymous2009-01-14 14:27
LISP
Name:
Anonymous2009-03-06 5:50
Simple vertical shooter games in QBasic on a shitty 12mhz.