# Control Charts

A control chart displays measurements of process samples over time. The plot contains the measurements, user-defined specification limits, and process-defined control limits. You can use the chart to compare the process with its specifications—to see if it is in control or out of control.

Control activity might occur if the chart indicates an undesirable, systematic change in the process. You can then adjust the process to reduce the undesirable variation.

You can create any of the following types of control chart using the `controlchart` function.

• X-bar or mean

• Standard deviation

• Range

• Exponentially weighted moving average

• Individual observation

• Moving range of individual observations

• Moving average of individual observations

• Proportion defective

• Number of defectives

• Defects per unit

• Count of defects

You can specify control rules using the `controlrules` function. The following example illustrates how to use Western Electric rules to flag out of control measurements on an X-bar chart.

`load parts`

Create an X-bar chart using the Western Electric 2 rule (2 of 3 consecutive points are at least two standard errors above the center line) to flag the out of control measurements. Return the subgroup statistics and parameter estimates.

`st = controlchart(runout,Rules="we2");`

Calculate the standard error and plot a magenta line on the chart that corresponds to two standard errors above the center line.

```x = st.mean; cl = st.mu; se = st.sigma./sqrt(st.n); hold on plot(cl+2*se,"m")```

Use the `controlrules` function to identify the measurements that violate the control rule.

```R = controlrules("we2",x,cl,se); I = find(R)```
```I = 6×1 21 23 24 25 26 27 ```

The function identifies six out of control measurements.