Documentation |
Shewhart control charts
controlchart(X)
controlchart(x,group)
controlchart(X,group)
[stats,plotdata] = controlchart(x,[group])
controlchart(x,group,'name',value)
controlchart(X) produces an xbar chart of the measurements in matrix X. Each row of X is considered to be a subgroup of measurements containing replicate observations taken at the same time. The rows should be in time order. If X is a time series object, the time samples should contain replicate observations.
The chart plots the means of the subgroups in time order, a center line (CL) at the average of the means, and upper and lower control limits (UCL, LCL) at three standard errors from the center line. The standard error is the estimated process standard deviation divided by the square root of the subgroup size. Process standard deviation is estimated from the average of the subgroup standard deviations. Out of control measurements are marked as violations and drawn with a red circle. Data cursor mode is enabled, so clicking any data point displays information about that point.
controlchart(x,group) accepts a grouping variable group for a vector of measurements x. group is a categorical variable, vector, string array, or cell array of strings the same length as x. Consecutive measurements x(n) sharing the same value of group(n) for 1 ≤ n ≤ length(x) are defined to be a subgroup. Subgroups can have different numbers of observations.
controlchart(X,group) accepts a grouping variable group for a matrix of measurements in X. In this case, group is only used to label the time axis; it does not change the default grouping by rows.
[stats,plotdata] = controlchart(x,[group]) returns a structure stats of subgroup statistics and parameter estimates, and a structure plotdata of plotted values. plotdata contains one record for each chart.
The fields in stats and plotdata depend on the chart type.
The fields in stats are selected from the following:
mean — Subgroup means
std — Subgroup standard deviations
range — Subgroup ranges
n — Subgroup size, or total inspection size or area
i — Individual data values
ma — Moving averages
mr — Moving ranges
count — Count of defects or defective items
mu — Estimated process mean
sigma — Estimated process standard deviation
p — Estimated proportion defective
m — Estimated mean defects per unit
The fields in plotdata are the following:
pts — Plotted point values
cl — Center line
lcl — Lower control limit
ucl — Upper control limit
se — Standard error of plotted point
n — Subgroup size
ooc — Logical that is true for points that are out of control
controlchart(x,group,'name',value) specifies one or more of the following optional parameter name/value pairs, with name in single quotes:
charttype — The name of a chart type chosen from among the following:
'xbar' — Xbar or mean
's' — Standard deviation
'r' — Range
'ewma' — Exponentially weighted moving average
'i' — Individual observation
'mr' — Moving range of individual observations
'ma' — Moving average of individual observations
'p' — Proportion defective
'np' — Number of defectives
'u' — Defects per unit
'c' — Count of defects
Alternatively, a parameter can be a cell array listing multiple compatible chart types. There are four sets of compatible types:
'xbar', 's', 'r', and 'ewma'
'i', 'mr', and 'ma'
'p' and 'np'
'u' and 'c'
display — Either 'on' (default) to display the control chart, or 'off' to omit the display
label — A string array or cell array of strings, one per subgroup. This label is displayed as part of the data cursor for a point on the plot.
lambda — A parameter between 0 and 1 controlling how much the current prediction is influenced by past observations in an EWMA plot. Higher values of 'lambda' give less weight to past observations and more weight to the current observation. The default is 0.4.
limits' — A three-element vector specifying the values of the lower control limit, center line, and upper control limits. Default is to estimate the center line and to compute control limits based on the estimated value of sigma. Not permitted if there are multiple chart types.
mean — Value for the process mean, or an empty value (default) to estimate the mean from X. This is the p parameter for p and np charts, the mean defects per unit for u and c charts, and the normal mu parameter for other charts.
nsigma — The number of sigma multiples from the center line to a control limit. Default is 3.
parent — The handle of the axes to receive the control chart plot. Default is to create axes in a new figure. Not permitted if there are multiple chart types.
rules — The name of a control rule, or a cell array containing multiple control rule names. These rules, together with the control limits, determine if a point is marked as out of control. The default is to apply no control rules, and to use only the control limits to decide if a point is out of control. See controlrules for more information. Control rules are applied to charts that measure the process level (xbar, i, c, u, p, and np) rather than the variability (r, s), and they are not applied to charts based on moving statistics (ma, mr, ewma).
sigma — Either a value for sigma, or a method of estimating sigma chosen from among 'std' (the default) to use the average within-subgroup standard deviation, 'range' to use the average subgroup range, and 'variance' to use the square root of the pooled variance. When creating i, mr, or ma charts for data not in subgroups, the estimate is always based on a moving range.
specs — A vector specifying specification limits. Typically this is a two-element vector of lower and upper specification limits. Since specification limits typically apply to individual measurements, this parameter is primarily suitable for i charts. These limits are not plotted on r, s, or mr charts.
unit — The total number of inspected items for p and np charts, and the size of the inspected unit for u and c charts. In both cases X must be the count of the number of defects or defectives found. Default is 1 for u and c charts. This argument is required (no default) for p and np charts.
width — The width of the window used for computing the moving ranges and averages in mr and ma charts, and for computing the sigma estimate in i, mr, and ma charts. Default is 5.