"Sean " <firstname.lastname@example.org> wrote in message <email@example.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 ML-ing