Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.


Jos
Posts:
1,268
Registered:
10/24/08


Re: Rand and sum of #s
Posted:
Jan 31, 2013 5:17 AM


"Sean " <swalsh@nmt.edu> wrote in message <kecmk0$ln5$1@newscl01ah.mathworks.com>... > So I'm using this code > % Create a vector of 53 random #s and analyze them. > r = rand([53,1]) > % The sum of all the random numbers > sum=sum(([53,1])) > disp(result) > > But it doesn't seem to be working. > I'm new to ML > How do I find the sum (and product) of the random numbers?
SUM is the name of a function that expects an input. Such an input can be numbers directly sum([1 2 3]) or these numbers can be stored in a variable myvariable = [3 4 5] sum(myvariable)
You may wish to store the result of SUM into a new variable myresult = sum(...) % replace ...
Be careful how you name your variables. If the happen to be the same name as functions (as in your code above), that function is no longer available until you CLEAR the variable.
RAND is a also function, DISP too ... I do suggest you read the Getting Started section of the documentation and good luck in MLing
hth ~ Jos


Date

Subject

Author

1/31/13


Jos

1/31/13


dpb


