How to insert a column of zero into a 3D matrix?

조회 수: 9 (최근 30일)
parslee
parslee 2022년 3월 30일
답변: Simon Chan 2022년 3월 30일
A = rand(128,256,36);
B = zeros(128,1);
I would like to concatenate B and A so that C = cat(2,B,A(:,:,1) but for every A(:,:,1), A(:,:,2), ... A(:,:,3).
How can I do this, instead of doing it manually?

채택된 답변

Simon Chan
Simon Chan 2022년 3월 30일
Try this
C=cat(2,A,repmat(B,1,1,size(A,3)));

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by