Adding a second layer to a 2D matrix
11 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Alex Flores
le 16 Avr 2017
Réponse apportée : Image Analyst
le 16 Avr 2017
I have having issues with trying to figure out how to add a second layer to a 2d matrix. I created a 4x4 matrix of random integers from -10 to 10. Now I have to add a second layer to the matrix so that it is 4x4x2. The new layer needs to be all zeros and it has to be done within one line of code. I have tried several things but nothing seems to work. Thanks in advance!
0 commentaires
Réponse acceptée
Image Analyst
le 16 Avr 2017
Try cat(3,...)
newMatrix = cat(3, old2DMatrix, second2DLayer); % Will be 4x4x2
Use your own variable names, needless to say.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Get Started with MATLAB dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!