clear allclose allclcn=xlsread('statTest.xls',5,'C2:C51'); % sample size set
p=xlsread('statTest.xls',5,'D2:D51'); % probability of having the non-confirming units
pAverage=(sum(p))/(sum(n)); % average probability of defects
% construct the p-chart
n=50;c=1;while c<=50; CL(c)=pAverage; % centraline vector
LCL(c)=pAverage-3*((pAverage*(1-pAverage)/n)^(0.5)); % upper control limit vector
UCL(c)=pAverage+3*((pAverage*(1-pAverage)/n)^(0.5)); % lower control limit vector
si1(c)=CL(c)+((UCL(c)- CL(c))/3); si2(c)=si1(c)+((UCL(c)- CL(c))/3); si3(c)=CL(c)-(CL(c)/3); si4(c)=si3(c)-(CL(c)/3); if LCL(c)<0; % lower control limit can not be negative
LCL(c)=0; end c=c+1; end% construct the time vector
t=1:50; % construct the p-chartfigureplot(t,UCL,'k--',t,si1,'m:',t,si2,'g:', t,CL,'-',t,si3,'m:',t,si4,'g:', t,LCL,'k--',t, p,'*:'); hold onlegend('UCL','1Sigma','2Sigma','CL','1Sigma','2Sigma','LCL')xlabel('defects')ylabel('c')
MATLAB: Hi, I have a question about displaying the line limit for p-chart. The line always displayed in y=0.
control chartp-chartstatistical process control
Best Answer