# Doegen

## Contents

### Purpose

Generate a Design of Experiments (DOE) DataSet object.

### Synopsis

- [doe,msg] = doegen(type,factors,scales,levels,options)

### Description

Creates a Design of Experiements of a specified type with named factors designed with a specified number of levels and coding of those levels at specified values or categorical names.

Designs can be a mix of numerical and categorical factors. The type of factor is defined by the "scales" input which specifies either the minimum and maximum values to use (numerical factor), the exact numerical values to be used (numerical factor), or the names of the categories (categorical factor).

Some design types have a specific number of levels which they allow. If one or more categorical factors requires a different number of levels than the design allows, the design is calculated without these categorical factor(s) and then replicated for all levels of the factor(s). This may increase the number of required samples beyond what is expected but provides full resolution of categorical factors in designs which would otherwise be incompatible with them.

#### Inputs

**type**= Type of design to create:

- 'full' = full factorial
- '2' = 1/2 factorial (2-level)
- '4' = 1/4 factorial (2-level)
- '8' = 1/8 factorial (2-level)
- '16' = 1/16 factorial (2-level)
- 'face' = Face-centered Central Composite (3-level)
- 'sphere' = Sperical Central Composite (5-level)
- 'box' = Box-Behnken Design (3-level)

**factors**= Cell array indicating the name(s) of the factors. The number of strings indicates the total number of factors in the design.**scales**= Cell array containing either double vectors (for numerical factors) or cell arrays of strings (for categorical factors). For numerical factors, the doubles indicate the minimum and maximum values for each factor's levels (if only two values are in a given cell) or the specific level values (if more than two values are in the cell). If only two values are supplied, the number of levels to use must be passed in the (levels) input. For categorical factors, number of strings in the cell array defines the number of levels for the given factor.

- Example:
`{ [5 8 9 10] [ 100 200 ] {'treat A' 'treat B'} }`- Defines scaling for three factors. The first two are numerical factors: one with four specific levels (equal to 5 8 9 10), one with a min/max of 100 and 200, and a third categorical factor with the labels indicated for the two categories. If using a full-factorial design and the second factor should have more than two levels, the (levels) input must be provided (see below.)

#### Optional Inputs

**levels**= Vector specifying the number of levels to use for each factor in a full-factorial design. Although a vector equal in length to the number of factors must be supplied, the values are ONLY used for non-categorical (i.e. numeric) factors when (scales) has been specified with only two values (min/max) and only for full-factorial designs. In all other cases, the number of levels is either predefined by the design or the number of elements in the (scales) input. However, when required by any factor, a value must be supplied for all factors (even if only a placeholder value). For example, if (scales) defines three factors:

- { [5 8 9 10] [ 100 200 ] {'treat A' 'treat B'} }
- then factors 1 and 3 are unambiguiously defined as having 4 and 2 levels, respectively. If the (levels) input is not provided, it will be assumed that factor 2 should have only two levels. If factor 2 should have more levels, for example, 3 levels at 100 150 and 200, the levels input needs to be defined as:
- [ 4 3 2]
- Notice that this input can be completely dropped if the (scales) input specifically defines the number and values of all factor levels.

#### Outputs

**desgn**= Output (desgn) is the matrix of the experimental design. If levl=2 then this gives a 2^k design.

### Example

>> desgn = factdes(3,[2 2 3]) desgn = -1 -1 -1 -1 -1 0 -1 -1 1 -1 1 -1 -1 1 0 -1 1 1 1 -1 -1 1 -1 0 1 -1 1 1 1 -1 1 1 0 1 1 1