Neural Network Toolbox Previous page   Next Page

Block Generation

The function gensim generates block descriptions of networks so you can simulate them in Simulink.

The second argument to gensim determines the sample time, which is normally chosen to be some positive real value.

If a network has no delays associated with its input weights or layer weights, this value can be set to -1. A value of -1 tells gensim to generate a network with continuous sampling.

Example

Here is a simple problem defining a set of inputs p and corresponding targets t.

The code below designs a linear layer to solve this problem.

We can test the network on our original inputs with sim.

The results returned show the network has solved the problem.

Call gensim as follows to generate a Simulink version of the network.

The second argument is -1 so the resulting network block samples continuously.

The call to gensim results in the following screen. It contains a Simulink system consisting of the linear network connected to a sample input and a scope.

To test the network, double-click on the Input 1 block at left.

The input block is actually a standard Constant block. Change the constant value from the initial randomly generated value to 2, and then select Close.

Select Start from the Simulation menu. Simulink momentarily pauses as it simulates the system.

When the simulation is over, double-click the scope at the right to see the following display of the network's response.

Note that the output is 3, which is the correct output for an input of 2.


Previous page  Transfer Function Blocks Exercises Next page

© 1994-2005 The MathWorks, Inc.