Summing randomly generated numbers
2 views (last 30 days)
Show older comments
I want to randomly generate two numbers between 0 and 1, and then sum those two numbers together. How would I go about doing this?
I currently have my randomly generated numbers coded as:
n1 = 0:0.1:0.9;
n2 = 0:0.1:0.9;
disp(n1(randi([1,numel(n1)])));
disp(n2(randi([1,numel(n2)])));
0 Comments
Answers (1)
KSSV
on 26 Feb 2021
n1 = 0:0.1:0.9;
n2 = 0:0.1:0.9;
r1 = n1(randi([1,numel(n1)]));
r2 = n2(randi([1,numel(n2)]));
thesum = r1+r2
0 Comments
See Also
Categories
Find more on Sources in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!