# Difference between revisions of "Constrainfit"

## Contents

### Purpose

Finds A minimizing ||X-A*B'|| subject to constraints, given the small matrices (X ' B) and (B ' B)

### Synopsis

[A]=constrainfit(XB,BtB,Aold); % Unconstrained
opt = constrainfit('options');
opt.type='nonnegativity';
[A]=constrainfit(XB,BtB,Aold,opt); % Nonnegative
opt = constrainfit('options');
opt.type='columnwise';
opt.columnconstraints={0;2;0}; % If three columns
[A]=constrainfit(XB,BtB,Aold,opt); % Second column unimodal

### Description

CONSTRAINTFIT solves the least squares problem behind bilinear, trilinear and other multilinear models. Assuming a model X = A*B ' and assuming that X and B are known, the least squares estimate of A is obtained. Rather than using X and B this algorithm uses the cross product matrices (X ' B) and (B ' B) which are generally smaller and less memory-demanding especially in multi-way models.

#### Inputs

• first = first input is this.

#### Optional Inputs

• second = optional second input is this.

#### Outputs

• firstout = first output is this.

### Options

options = a structure array with the following fields:

• plots: [ {'none'} | 'final' ] governs plotting of results, and
• order: positive integer for polynomial order {default = 1}.

### Example

```>>This is an example
Error: does not exist
```