Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

matlab

Name: Anonymous 2007-04-25 23:08 ID:mq92LVE1

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: Anonymous 2007-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

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List