Respuesta :
Answer:
The can be done by using the rand function in Mathlab.
x = rand(1,50)
Explanation:
This can be achieved by using the rand function in MathLab to generate the random numbers. We will ask the rand function to generate random numbers in 1-by-50 matrix. The 50 column of the matrix will represent the 50 people. While the row will be the random number generated for each person.
>> x=rand(1,50)
x =
Columns 1 through 12
0.1626 0.1190 0.4984 0.9597 0.3404 0.5853 0.2238 0.7513 0.2551 0.5060 0.6991 0.8909
Columns 13 through 24
0.9593 0.5472 0.1386 0.1493 0.2575 0.8407 0.2543 0.8143 0.2435 0.9293 0.3500 0.1966
Columns 25 through 36
0.2511 0.6160 0.4733 0.3517 0.8308 0.5853 0.5497 0.9172 0.2858 0.7572 0.7537 0.3804
Columns 37 through 48
0.5678 0.0759 0.0540 0.5308 0.7792 0.9340 0.1299 0.5688 0.4694 0.0119 0.3371 0.1622
Columns 49 through 50
0.7943 0.3112
Explanation:
The Matlab function rand() is used to generate uniformly distributed random numbers of a given size over the interval (0, 1)
Syntax:
num = rand(N, 1)
Where num is a variable to store the random numbers
N is the number of random numbers you want to generate.
Example:
For the given problem we have to generate one random number for each person in the class of 50 people.
num = rand(50,1)
It returns 50 random numbers in the range 0 to 1 which are given in the output section.
You can also modify the range of interval by adding the following code
num = x + (y - x).*rand(1,50)
Where x is the lower limit of the range and y is the upper limit of the range.
for example
num = 50 + (100 - 50).*rand(1,50)
it will generate random numbers in the range of 50 to 100. Here .* is used for the bit-wise multiplication
Note:
Do not write rand(50) it will return a 50 by 50 matrix of random numbers.
Output:
num =
0.582139
0.540686
0.350985
0.115957
0.652881
0.195352
0.425562
0.367363
0.169750
0.800792
0.267118
0.586340
0.698618
0.975052
0.235557
0.757331
0.117483
0.295195
0.624606
0.857645
0.196915
0.645716
0.041070
0.718010
0.469060
0.116754
0.256292
0.472404
0.221682
0.888215
0.379500
0.464798
0.604826
0.521442
0.351424
0.730017
0.459121
0.241424
0.140979
0.729892
0.600992
0.961623
0.781636
0.671102
0.628573
0.660506
0.605492
0.033747
0.659619
0.274432