필터 지우기
필터 지우기

Adding a second layer to a 2D matrix

조회 수: 11 (최근 30일)
Alex Flores
Alex Flores 2017년 4월 16일
답변: Image Analyst 2017년 4월 16일
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!

채택된 답변

Image Analyst
Image Analyst 2017년 4월 16일
Try cat(3,...)
newMatrix = cat(3, old2DMatrix, second2DLayer); % Will be 4x4x2
Use your own variable names, needless to say.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by