Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

MATLAB Code for the following problem A machine composed of a chain of blocks is

ID: 2085740 • Letter: M

Question

MATLAB Code for the following problem

A machine composed of a chain of blocks is shown. Each block operates independently and has a failure rate of 2% = 0.02. The machine will properly function as long as there is an un-interrupted path from left to right. Write a Matlab program to simulate the overall reliability of the machine. The simulation is to be set up in a loop, with each iteration of the loop corresponding to one trial of the experiment. During each iteration, use the Matlab built-in function rand() to generate a random number for each block of the machine. The rand() function generates random numbers uniformly in (0,1). Compare each random number with a threshold (you much properly choose it) to determine whether the corresponding block is functional. Once you have determined the status of all blocks, use decision to determine whether a clear path exists. Keep track of the number of trials where the machine is functioning. Run the simulation for 100000 iterations, and estimate the reliability by calculating the relative frequency. The above description also offers a common strategy on how to run simulations of random systems.

Explanation / Answer

Ans. Each block independently has a failure rate of 2%. Thus, each block has a sucess rate of 98%. The machine will function properly if all of the below conditions are satisfied:
1.L1 and L3 are functional(since they are in series)

2.either L2a or L2b or L2c are functional(since they are connected in parallel)

3. either L4a and L5a are functional(since L4a and L5a are in series) or L4b and L5b are functional(since L4b and L5b are in series)

Machine operation is successful when all of these conditions are met. This is checked in matlab code using if condition.

The required matlab code is given below('%' indicates comments added to help in understandin the code)

success_sum=0;% this variable will store the no.of succesful experiments

for i=1:100000
l1=rand >0.02;
% l1=1(i.e.rand>0.02) means block L1 is functional, in 100000 experiments,this should happen with a probability of ~98%

l2a=rand >0.02;
% l2a=1(i.e.rand>0.02) means block L2a is functional, in 100000 experiments,this should happen with a probability of ~98%
l2b=rand >0.02;
% l2b=1(i.e.rand>0.02) means block L2b is functional, in 100000 experiments,this should happen with a probability of ~98%
l2c =rand>0.02;
% l2c=1(i.e.rand>0.02) means block L2c is functional, in 100000 experiments,this should happen with a probability of ~98%

l3=rand>0.02;
% l3=1(i.e.rand>0.02) means block L3 is functional, in 100000 experiments,this should happen with a probability of ~98%

l4a=rand>0.02;
% l4a=1(i.e.rand>0.02) means block L4a is functional, in 100000 experiments,this should happen with a probability of ~98%

l4b=rand>0.02;
% l4b=1(i.e.rand>0.02) means block L4b is functional, in 100000 experiments,this should happen with a probability of ~98%

l5a=rand>0.02;
% l5a=1(i.e.rand>0.02) means block L5a is functional, in 100000 experiments,this should happen with a probability of ~98%
l5b=rand>0.02;
% l5b=1(i.e.rand>0.02) means block L5b is functional, in 100000 experiments,this should happen with a probability of ~98%

if((l1==1)&&((l2a==1)||(l2b==1)||(l2c==1))&&(l3==1)&&(((l4a==1)&&(l5a==1))||((l4b==1)&&(l5b==1))))
% checks if a clear path exists from left to right
success_sum=success_sum+1;
% counts no. of times a clear path exists from left to right(i.e. counts no. of trials when the machine is functioning)
end
end

display(success_sum); % displays no. of trials when machine is functioning
display(i); % displays total no. of trials
  
reliability=(success_sum/i); %calculates reliability as (no. of succesful trials)/(total no. of trials)
display(reliability);