i have a 48*48*3 matrix , i want to convert it to 48*48 matrix where each element of the matrix will show a list of 3 characters in a cell. how to do it?

조회 수: 1 (최근 30일)
for eg-
i need this matrix to look like {1,9} {2,7} {3,8}.......
  댓글 수: 3

댓글을 달려면 로그인하십시오.

채택된 답변

Image Analyst
Image Analyst 2018년 9월 14일
편집: Image Analyst 2018년 9월 14일
For all the numbers, you can try this:
[rows, columns, numSlices] = size(m);
index = 1;
ca = cell(1, rows*columns); % Preallocate
for row = 1 : rows
for col = 1 : columns
ca{index} = m(row, col, :);
index = index + 1;
end
end

추가 답변 (2개)

Matt J
Matt J 2018년 9월 14일
편집: Matt J 2018년 9월 14일
Acell=cellfun( @(c) c(:).', num2cell(A,3), 'uni',0 );

Image Analyst
Image Analyst 2018년 9월 14일
Did you try something like this:
[rows, columns, numSlices] = size(m);
index = 1;
ca = cell(1, rows*columns); % Preallocate
for row = 1 : rows
for col = 1 : columns
ca{index} = [m(row, col, 1), m(row, col, end)];
index = index + 1;
end
end

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by