Neural network fitting for PWM synthesis

Illustration
mohitram12 - 2021-06-14T12:34:34+00:00
Question: Neural network fitting for PWM synthesis

While generating a neural network function for the given block The following error occured .What is the reason behind this and how to debug it     net = network( ... 1, ... % numInputs, number of inputs, 2, ... % numLayers, number of layers [1; 0], ... % biasConnect, numLayers-by-1 Boolean vector, [1; 0], ... % inputConnect, numLayers-by-numInputs Boolean matrix, [0 0; 1 0], ... % layerConnect, numLayers-by-numLayers Boolean matrix [0 1] ... % outputConnect, 1-by-numLayers Boolean vector ); >> view(net); >> net.layers{1}.size=25; >> net.layers{1}.transferFcn = 'logsig'; >> view(net); >> net.layers{2}.size=3; >> net.layers{2}.transferFcn = 'logsig'; >> view(net); >> net.layers{3}.size=3; Error using network/subsasgn>network_subsasgn (line 169) Index exceeds the number of array elements (2). Error in network/subsasgn (line 14)

Expert Answer

Profile picture of John Michell John Michell answered . 2025-11-20

According to your code:
 
 
net = network( ...
1, ... % numInputs, number of inputs,
2, ... % numLayers, number of layers
[1; 0], ... % biasConnect, numLayers-by-1 Boolean vector,
[1; 0], ... % inputConnect, numLayers-by-numInputs Boolean matrix,
[0 0; 1 0], ... % layerConnect, numLayers-by-numLayers Boolean matrix
[0 1] ... % outputConnect, 1-by-numLayers Boolean vector
);

The network has only 2 layers.

>> view(net)
>> net.layers

ans =

  2×1 cell array

    {1×1 nnetLayer}
    {1×1 nnetLayer}


Not satisfied with the answer ?? ASK NOW

Get a Free Consultation or a Sample Assignment Review!