i'm trying to make a time sequence monte carlo simulation for reliability analysis. The failure rate/year λ of my system is a constant so i generate random numbers from the exponential distribution with exprnd(1/λ) to calculate possible future failure times(years).The monte carlo simulation period will be 30 years and the number of experiments will be user defined -k.The results from each iteration will be stored in matrix and each column will be the failure times of my system during its 30 years life cycle.The problem is that i don't know the exact iterations of the while loop.The code for one 30year period will be similar to the following
MTTF=0.6; % enter mean time to failure 1/λ
A=zeros(300,1); %preallocate a large enough vector
t=0;
n=1;
while t<30 %time is less than 30 years of simulation
hup=exprnd(MTTF);%generate random failure time
t=t+hup;
A(n)=t;
n=n+1;
end