Neural network fitting for PWM synthesis

M
mohitram12 · Jun 14, 2021 · 2K views
Question
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 PhD Expert
Answered Aug 11, 2026
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}
Have a different question? Ask here

Get a Free Consultation or a Sample Assignment Review!