Reshaping 3D function to 2D

조회 수: 18 (최근 30일)
Lesley Quin
Lesley Quin 2016년 8월 11일
편집: Azzi Abdelmalek 2016년 8월 11일
Write the function RepTile() that accepts a 2x2x2 array as input. Then transforms that input into a 2x4 array. And it tiles the 2x4 array 3 times vertically and twice horizontally. The resulting 6x8 array is its output
So far I have the follow code. Im getting a "Error using reshape. To RESHAPE the number of elements must not change"
function [myRepTile] = RepTile(mxtrx2)
tmp = reshape(mxtrx2,[2 4]);
tmp = repmat(mxtrx2,[3 2]);
myRepTile = tmp;
end

답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2016년 8월 11일
편집: Azzi Abdelmalek 2016년 8월 11일
A=randi(2,2,2,2)
B=repmat(A(:,:),3,2)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by