Main Content

controlrules

Western Electric and Nelson control rules

Description

R = controlrules(rules,X,cl,se) returns violation indicators for the points in the numeric vector X, using the rules in rules, center line values cl and standard errors se. If X contains n points and rules contains m rules, then R is an n-by-m logical matrix, where R(i,j) has the value true (logical 1) if point i violates rule j, and a value false (logical 0) if it does not. If rules contains only one control rule, then R is a logical vector of length n.

example

[R,appliedRules] = controlrules(___) additionally returns a cell array containing the names of the applied control rules.

Examples

collapse all

Load the parts data set.

load parts;

Create an X-bar chart with controlchart using the we4 rule to mark out of control measurements. Return the subgroup statistics and plot data.

[stats,plotted] = controlchart(runout,rules="we4");

Figure contains an axes object. The axes object with title XBAR control chart, ylabel XBAR contains 4 objects of type line. One or more of the lines displays its values using only markers These objects represent Data, Violation, Center, LCL/UCL.

The software marks the out of control points marked with a red circle. Display the subgroup numbers of the out of control points.

find(plotted.ooc)
ans = 4×1

     2
    21
    25
    27

Use controlrules to identify the measurements that violate the we4 control rule.

R = controlrules("we4",plotted.pts,plotted.cl(1),plotted.se(1));
I = find(R)
I = 
27

The subgroups 2, 21, and 25 are out of control since they are outside the control limits delineated by the red lines. Subgroup 27 is in violation of the we4 control rule, since it is the last of eight consecutive points that lie above the center line.

Input Arguments

collapse all

Control rules, specified as a character vector, string scalar, string array, or cell array of character vectors containing one or more of the following values.

ValueViolation Condition
"we1"

One point above cl + 3*se

"we2"

Two of three points above cl + 2*se

"we3"

Four of five points above cl + se

"we4"Eight of eight points above cl
"we5"

One point below cl 3*se

"we6"

Two of three points below cl 2*se

"we7"

Four of five points below cl se

"we8"Eight of eight points below cl
"we9"

15 of 15 points between cl se and cl + se

"we10"

Eight of eight points below cl se or above cl + se

"n1"

One point below cl 3*se or above cl + 3*se

"n2"Nine of nine points on the same side of cl
"n3"Six of six points increasing or decreasing
"n4"14 points alternating up or down
"n5"

Two of three points below cl 2*se or above cl + 2*se, all on the same side

"n6"

Four of five points below cl se or above cl + se, all on the same side

"n7"

15 of 15 points between cl se and cl + se

"n8"

Eight of eight points below cl se or above cl + se, on either side

"we"All Western Electric rules (beginning with the letters "we")
"n"All Nelson rules (beginning with the letter "n")

For the control rules that involve more than a single point, a rule violation at point i indicates that the set of consecutive points ending at point i trigger the rule. R(i) is true only if the point i is one of the points that violates the rule's condition.

Any point whose X, cl, or se value is NaN is not counted in rules that involve more than a single point, and always has an R value of false (logical 0).

Example: rules=["we","n"]

Data Types: char | string

Points to evaluate, specified as a numeric vector.

Data Types: single | double

Center lines, specified as a numeric vector that has the same length as X. You can also specify cl as a numeric scalar. In this case, the software uses the same value for all points.

Example: cl=1.5

Data Types: single | double

Standard errors, specified as a numeric vector that has the same length as X. You can also specify se as a numeric scalar. In this case, the software uses the same value for all points.

Example: se=2.5

Data Types: single | double

Output Arguments

collapse all

Control rule violation indicators for the points in X, using the rules in rules, center line values cl, and standard errors se. If X contains n points and rules contains m rules, then R is an n-by-m logical matrix, where R(i,j) has the value true (logical 1) if point i violates rule j, and a value false (logical 0) if it does not. If rules contains only one control rule, R is a logical vector of length n.

Applied control rules, returned as a cell array of character vectors. If rules includes "we" or "n", all of the associated individual rules are included in appliedRules.

Version History

Introduced in R2006b

See Also