You are on page 1of 4

REPORT ON MATLAB RANDOM

NUMBER GENERATOR
DONE BY:ASEM ABDULRAHMAN HANASH ALZAHRANI
ID:441009587
Dr:Shawqi
Introduction:
Random numbers are fundamental building blocks for a wide range of applications
in science and engineering. From modeling physical phenomena to simulating
complex systems, the ability to generate unpredictable yet statistically controlled
values is crucial. In MATLAB, the randi function provides a powerful tool for
generating discrete, uniformly distributed random integers within a specified
range. This report offers a comprehensive exploration of randi, examining its key
features, usage considerations, and potential applications.

% Random Number Generator from 1 to 10 in MATLAB

% Generate a random number


randomNumber = randi([1, 10]);

% Display the generated number


disp([(randomNumber);
the output

Generated RandomNumber:8
Objective:
The objective of this script is to generate a random integer between 1 and 10
using MATLAB. This is a basic example of utilizing random number generation in
MATLAB.

Method:
The MATLAB function randi is used for this purpose. The randi function is designed
to generate pseudorandom integers. In this script, randi is configured to produce a
number in the range from 1 to 10.

Code Description:
The code consists of the following parts:
 Random Number Generation:
The function randi([1, 10]) is used. This function generates a random integer
where the range [1, 10] specifies that the output should be between 1 and 10,
inclusive.
 Displaying the Result:
The generated random number is then displayed using the disp function.
Usage:
This script can be used in scenarios where a random integer in a specified range is
required. It's a basic utility that can be integrated into larger programs for
simulations, games, random sampling, etc.
Conclusion:
The script effectively demonstrates the generation of a random integer in a
specified range using MATLAB. It serves as a foundational example of random
number generation in programming.

You might also like