Write a Matlab code that will generate a random number which
Solution
Important: Change the values of n according to your student ID number.
Code
%For 10 random trials
%generating 10 random numbers
 prob10 = randi([0 1], 1, 10);
%initialising number of heads
 H = 0;
%iterating through the number of trials
 for i=1:1:10
     if prob10(i)==0
         H = H + 1;
     end
 end
%displaying probabilities
 disp([\'Probability of heads for 10 trials = \', num2str(H/10.0)]);
 disp([\'Probability of tails for 10 trials = \', num2str(1-(H/(10.0)))]);
 %For 1XY random trials
n = 123;
%generating n random numbers
 prob1XY = randi([0 1], 1, n);
%initialising number of heads
 H = 0;
%iterating through the number of trials
 for i=1:1:n
     if prob1XY(i)==0
         H = H+1;
     end
 end
%displaying probabilities
 disp([\'Probability of heads for 123 trials = \', num2str(H/(n*1.0))]);
 disp([\'Probability of tails for 123 trials = \', num2str(1-(H/(n*1.0)))]);
 %For 5XY random trials
n = 523;
 %generating n random numbers
 prob5XY = randi([0 1], 1, n);
%initialising number of heads
 H = 0;
%iterating through the number of trials
 for i=1:1:n
     if prob5XY(i)==0
         H = H+1;
     end
 end
%displaying probabilities
 disp([\'Probability of heads for 523 trials = \', num2str(H/(n*1.0))]);
 disp([\'Probability of tails for 523 trials = \', num2str(1-(H/(n*1.0)))]);
 %For 1XYZ random trials
n = 1234;
%generating 10 random numbers
 prob1XYZ = randi([0 1], 1, n);
%initialising number of heads
 H = 0;
%iterating through the number of trials
 for i=1:1:n
     if prob1XYZ(i)==0
         H = H+1;
     end
 end
%displaying probabilities
 disp([\'Probability of heads for 1234 trials = \', num2str(H/(n*1.0))]);
 disp([\'Probability of tails for 1234 trials = \', num2str(1-(H/(n*1.0)))]);


