help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Help! (Loops)


From: Monstah
Subject: Help! (Loops)
Date: Tue, 12 May 2009 12:22:31 -0700 (PDT)

I'm working with Octave right now and I'm struggling with Loops. 

The instructions to my assignment are: Prompt to user to enter 50 data using
a for loop.
Calculate the mean (average), maximum, minimum, median and standard
deviation of the data entered using your own calculations.  Do some research
on these calculations.  You will need to use loop(s) to calculate each of
the values.  (Do not calculate all values in one loop). 


This is what I've done: 

octave-3.0.1:1> a = [1:50]
> a =
> 
>  Columns 1 through 16:
> 
>     1    2    3    4    5    6    7    8    9   10   11   12   13   14  
> 15   16
> 
>  Columns 17 through 32:
> 
>    17   18   19   20   21   22   23   24   25   26   27   28   29   30  
> 31   32
> 
>  Columns 33 through 48:
> 
>    33   34   35   36   37   38   39   40   41   42   43   44   45   46  
> 47   48
> 
>  Columns 49 and 50:
> 
>    49   50
> 
> octave-3.0.1:2> for b = a(1:16)
>> b
>> endfor
> b =  1
> b =  2
> b =  3
> b =  4
> b =  5
> b =  6
> b =  7
> b =  8
> b =  9
> b =  10
> b =  11
> b =  12
> b =  13
> b =  14
> b =  15
> b =  16
> octave-3.0.1:3> for c = a(17:32)
>> c
>> endfor
> c =  17
> c =  18
> c =  19
> c =  20
> c =  21
> c =  22
> c =  23
> c =  24
> c =  25
> c =  26
> c =  27
> c =  28
> c =  29
> c =  30
> c =  31
> c =  32
> octave-3.0.1:4> for d = a(33:48)
>> d
>> endfor
> d =  33
> d =  34
> d =  35
> d =  36
> d =  37
> d =  38
> d =  39
> d =  40
> d =  41
> d =  42
> d =  43
> d =  44
> d =  45
> d =  46
> d =  47
> d =  48
> octave-3.0.1:5> for e = a(49:50)
>> e
>> endfor
> e =  49
> e =  50
> octave-3.0.1:6> mean (a)
> ans =  25.500
> octave-3.0.1:7> median (a)
> ans =  25.500
> octave-3.0.1:8> mode (a)
> ans =  1
> octave-3.0.1:9> std (a)
> ans =  14.577
> 

I don't think it's right. And then when I try and do mean, median, mode, and
standard deviation within the loops, it still doesn't come out looking
right. Can someone send me in the right direction?

Also, every time I try and make a loop out of anything more than 20 entries,
it turns it into a log file or something that I can't do anything with. I'm
not sure what to do :\


-- 
View this message in context: 
http://www.nabble.com/Help%21-%28Loops%29-tp23508760p23508760.html
Sent from the Octave - General mailing list archive at Nabble.com.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]