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


dpb
Posts:
8,511
Registered:
6/7/07


Re: Rand and sum of #s
Posted:
Jan 31, 2013 5:46 PM


On 1/30/2013 8:58 PM, Sean wrote: > 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) ...
Well, there is no variable "result" and you've aliased the builtin function 'sum()' and how would you expect that sum() would have known you wanted 'r' as it's input when you gave it a vector of two integers???
Start w/ the "Getting Started" section tutorial and work your way through some beginning steps...
For the question you've asked,
r=rand(53,1); % don't need the [] to make inputs a vector s=sum(r); % sum up the values you got... disp(s) % or forget trailing ";" & ML will echo automagically



Date

Subject

Author

1/31/13


Jos

1/31/13


dpb


