repair.m
来自「markov matlab code, give a detail implet」· M 代码 · 共 40 行
M
40 行
% repair.m sets up matrices for a model of the number of machines working% and the number in repairN = 40; % total number of machinesM = 30; % maximum number in useR = 3; % capacity of repair facilityS = 0:40; % state spacemu = zeros(1,N+1); % initial distributionmu(M+1) = 1; Tmax = 20; % maximum time for simulationdelta = 1; % rate at which failures occurrho = 10; % rate at which repairs occurA = zeros(N+1);for i=1:N, A(i+1,i) = delta*min(i,M); A(i,i+1) = rho*min(R,N+1-i);endfor i=1:N+1, A(i,i) = -sum(A(i,:));endlambda = -diag(A);Q = diag(1./lambda)*A+eye(size(A));subplot(3,1,1)processtitle('repair.m, N = 40, M = 30, R = 3, \delta = 1, \rho = 10')grid onsubplot(3,1,2)processgrid onsubplot(3,1,3)plot(0:N, invariant(expm(A)));title('Invariant distribution')
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?