# DOE with MATLAB 3

## Contents |

## Abstract

This example shows how to do multilevel full factorial designs and Taguchi designs using MATLAB.

Author(s): Mark A. Tschopp

## Introduction to D-optimal Designs in MATLAB

From MATLAB help:

"Traditional experimental designs (Full Factorial Designs, Fractional Factorial Designs, and Response Surface Designs) are appropriate for calibrating linear models in experimental settings where factors are relatively unconstrained in the region of interest. In some cases, however, models are necessarily nonlinear. In other cases, certain treatments (combinations of factor levels) may be expensive or infeasible to measure. D-optimal designs are model-specific designs that address these limitations of traditional designs.

A D-optimal design is generated by an iterative search algorithm and seeks to minimize the covariance of the parameter estimates for a specified model. This is equivalent to maximizing the determinant D = |XTX|, where X is the design matrix of model terms (the columns) evaluated at specific treatments in the design space (the rows). Unlike traditional designs, D-optimal designs do not require orthogonal design matrices, and as a result, parameter estimates may be correlated. Parameter estimates may also be locally, but not globally, D-optimal."

## Multilevel Full Factorial Design

What if we have four factors (a, b, c, d) at three levels (1 2 3)?

nfactors = 4; nlevels = 3; nruns = nlevels^nfactors; % 81 runs dfF = sortrows(rowexch(nfactors,nruns,'l','cat',1:nfactors,'levels',nlevels*ones([1,nlevels]),'tries',1)) |

which gives...

dfF = 1 1 1 2 1 1 1 2 1 1 2 1 1 1 2 2 1 1 2 3 1 1 2 3 1 1 2 3 1 1 3 1 1 1 3 3 1 2 1 1 1 2 1 3 1 2 1 3 1 2 2 1 1 2 2 2 1 2 3 1 1 2 3 1 1 2 3 1 1 2 3 2 1 3 1 1 1 3 1 2 1 3 1 3 1 3 1 3 1 3 2 1 1 3 2 3 1 3 3 2 1 3 3 2 1 3 3 2 2 1 1 2 2 1 1 2 2 1 1 3 2 1 2 1 2 1 2 2 2 1 2 3 2 1 3 1 2 1 3 2 2 1 3 2 2 2 1 1 2 2 1 1 2 2 1 2 2 2 1 2 2 2 2 2 2 2 2 3 2 2 3 3 2 2 3 3 2 2 3 3 2 3 1 1 2 3 1 3 2 3 2 1 2 3 2 1 2 3 2 1 2 3 2 2 2 3 3 1 2 3 3 3 2 3 3 3 3 1 1 1 3 1 1 1 3 1 1 1 3 1 1 3 3 1 2 1 3 1 3 1 3 1 3 2 3 1 3 3 3 1 3 3 3 2 1 2 3 2 1 2 3 2 2 1 3 2 2 2 3 2 2 2 3 2 2 3 3 2 2 3 3 2 3 1 3 2 3 3 3 3 1 2 3 3 1 3 3 3 1 3 3 3 2 1 3 3 2 2 3 3 2 3 3 3 3 1 3 3 3 2 3 3 3 2 |

What if we have four factors (a, b, c, d) at mixed levels (1 2 for 'a', 1 2 3 for 'b','c','d')? Just use...

nfactors = 4; nruns = 54; % 2*3*3*3 runs dfF = sortrows(rowexch(nfactors,nruns,'l','cat',1:nfactors,'levels',[2 3 3 3],'tries',1)) |

## Taguchi design

Here are the commands for L8, L12, L25 Taguchi design arrays. Notice that you can used the 'bounds' command to change the factor levels from 1 and 2 to evenly spaced numbers between bounds (-1 and +1 in this case). However, for the five factor levels in the L25 design, I removed the command to show the factor levels as 1-5. Within the Taguchi designs, 7 factors at 2 levels can be used in the L8 design, 11 factors at 2 levels can be used in the L12 design, and 5 factors at 5 levels can be used in the L25 design.

i = 7; L8 = sortrows(rowexch(i,8,'l','cat',1:i,'bounds',[-1*ones([1,i]);ones([1,i])],'levels',2*ones([1,i]),'tries',100)); i = 11; L12 = sortrows(rowexch(i,12,'l','cat',1:i,'bounds',[-1*ones([1,i]);ones([1,i])],'levels',2*ones([1,i]),'tries',100)); i = 5; L25 = sortrows(rowexch(i,25,'l','cat',1:i,'levels',5*ones([1,i]),'tries',100)); |

which give the following arrays...

### L8 array

Again, seven factors at two levels (-1 and +1).

L8 = -1 -1 -1 1 1 1 -1 -1 -1 1 -1 1 -1 1 -1 1 -1 -1 -1 1 1 -1 1 1 1 -1 -1 -1 1 -1 -1 -1 -1 -1 -1 1 -1 1 1 -1 1 1 1 1 -1 1 1 -1 1 1 1 1 -1 1 1 -1 |

### L12 array

Again, eleven factors at two levels (-1 and +1).

L12 = -1 -1 -1 1 -1 -1 1 1 -1 -1 1 -1 -1 -1 1 1 1 -1 -1 1 -1 -1 -1 -1 1 -1 1 -1 -1 1 -1 1 -1 -1 1 -1 -1 -1 1 1 1 1 1 -1 -1 1 1 -1 1 -1 1 -1 1 -1 1 -1 1 1 1 -1 1 -1 -1 -1 1 1 1 -1 -1 -1 -1 -1 -1 -1 1 1 1 1 -1 1 -1 -1 1 1 -1 -1 -1 -1 1 -1 1 1 1 1 1 1 1 1 1 1 1 -1 -1 1 1 -1 1 -1 -1 1 1 1 -1 1 1 -1 1 -1 -1 1 -1 1 1 1 1 -1 -1 -1 1 1 -1 -1 |

### L25 array

Again, five factors at five levels (1-5).

L25 = 1 1 2 5 3 1 2 4 1 2 1 3 5 2 4 1 4 3 4 5 1 5 1 3 1 2 1 4 4 4 2 2 1 5 5 2 3 3 3 2 2 4 2 2 1 2 5 5 1 3 3 1 3 1 1 3 2 2 3 4 3 3 1 4 3 3 4 5 5 2 3 5 4 2 5 4 1 5 3 5 4 2 3 2 3 4 3 4 5 1 4 4 1 1 4 4 5 2 4 2 5 1 1 2 2 5 2 5 4 1 5 3 2 1 5 5 4 4 3 3 5 5 3 5 4 |

### General

You can use these functions (sortrows, rowexch) to create other d-optimal designs. In some cases, obtaining the d-optimal designs for Taguchi matrices may not be very efficient with these functions or may require too much memory. In these cases, you can always enter the design matrix directly from Taguchi's generated matrices.

In general, if you want a different number of factors and factor levels than the traditional Taguchi design arrays, you can produce them using the following techniques. It is recommended that your designs are balanced. That is, the number of levels for each factor (each column above) are equal. If you have 8 runs with two factor levels for factor 'a', it is best to have a design where there are four combinations with 'a' at a low level and four combinations with 'a' at a high level, etc.