Question
If you have elements of 2D data that are put into a 3D inputs variable, is it possible to do pattern recognition on this data in MATLAB? >> inputs = rand(3,3,10); >> targets = ones(2,10); >> net = patternnet(10); >> net = train(net, inputs, targets) %error inputs must be 2D >> nprtool %dropdown does not give 3D inputs variable as an option
Expert Answer
Kshitij Singh
PhD Expert
Answered Sep 10, 2026
The input data for training classical neural networks is expected to be an R x Q dimensional matrix (or a cell array of R x Q matrices), where Q is the batch size or number of observations and R is the number of variables.
Since ‘patternnets’ (in general, not just in MATLAB) do not take account of spatial dependencies between variables (as opposed to convolutional deep learning networks) you could try to work around this requirement by reshaping the data from a 2D matrix into a 1D vector. For example:
Instead of:
inputs = rand(3,3,10) targets = ones(2,10);
You could use:
inputs = rand(9,10); targets = ones(2,10);
However, depending on what your 2-D data represents, a better alternative might be to work with convolutional neural networks (CNNs). These networks are designed to model spatial dependencies between variables/features and are the state-of-the-art for tasks such as image classification.
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 3d Questions & Solutions
Browse All →
Explore similar technical troubleshooting questions and verified MATLAB solutions:
Ready-to-Run MATLAB & Simulink Projects
Browse All Projects →