# newlind

Design linear layer

## Syntax

```net = newlind(P,T,Pi) ```

## Description

`net = newlind(P,T,Pi)` takes these input arguments,

 `P` `R`-by-`Q` matrix of `Q` input vectors `T` `S`-by-`Q` matrix of `Q` target class vectors `Pi` `1`-by-`ID` cell array of initial input delay states

where each element `Pi{i,k}` is an `Ri`-by-`Q` matrix, and the default = `[]`; and returns a linear layer designed to output `T` (with minimum sum square error) given input `P`.

`newlind(P,T,Pi)` can also solve for linear networks with input delays and multiple inputs and layers by supplying input and target data in cell array form:

 `P` `Ni`-by-`TS` cell array Each element `P{i,ts}` is an `Ri`-by-`Q` input matrix `T` `Nt`-by-`TS` cell array Each element `P{i,ts}` is a `Vi`-by-`Q` matrix `Pi` `Ni`-by-`ID` cell array Each element `Pi{i,k}` is an `Ri`-by-`Q` matrix, default = `[]`

and returns a linear network with `ID` input delays, `Ni` network inputs, and `Nl` layers, designed to output `T` (with minimum sum square error) given input `P`.

## Examples

You want a linear layer that outputs `T` given `P` for the following definitions:

```P = [1 2 3]; T = [2.0 4.1 5.9]; ```

Use `newlind` to design such a network and check its response.

```net = newlind(P,T); Y = sim(net,P) ```

You want another linear layer that outputs the sequence `T` given the sequence `P` and two initial input delay states `Pi`.

```P = {1 2 1 3 3 2}; Pi = {1 3}; T = {5.0 6.1 4.0 6.0 6.9 8.0}; net = newlind(P,T,Pi); Y = sim(net,P,Pi) ```

You want a linear network with two outputs `Y1` and `Y2` that generate sequences `T1` and `T2`, given the sequences `P1` and `P2`, with three initial input delay states `Pi1` for input 1 and three initial delays states `Pi2` for input 2.

```P1 = {1 2 1 3 3 2}; Pi1 = {1 3 0}; P2 = {1 2 1 1 2 1}; Pi2 = {2 1 2}; T1 = {5.0 6.1 4.0 6.0 6.9 8.0}; T2 = {11.0 12.1 10.1 10.9 13.0 13.0}; net = newlind([P1; P2],[T1; T2],[Pi1; Pi2]); Y = sim(net,[P1; P2],[Pi1; Pi2]); Y1 = Y(1,:) Y2 = Y(2,:) ```

## Algorithms

`newlind` calculates weight `W` and bias `B` values for a linear layer from inputs `P` and targets `T` by solving this linear equation in the least squares sense:

```[W b] * [P; ones] = T ```

## Version History

Introduced before R2006a