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)])));

답변 (1개)

KSSV
KSSV 2021년 2월 26일

0 개 추천

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
thesum = 1.3000

카테고리

도움말 센터File Exchange에서 Random Number Generation에 대해 자세히 알아보기

질문:

2021년 2월 26일

답변:

2021년 2월 26일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by