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
John Michell
PhD Expert
Answered Sep 17, 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}
100% Run Guarantee
3-Hour Fast-Track Delivery
Need a Custom Version or Complete Simulation for This Problem?
Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.
Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here
Related deep learning Questions & Solutions
Browse All →
Explore similar technical troubleshooting questions and verified MATLAB solutions:
Ready-to-Run MATLAB & Simulink Projects
Browse All Projects →