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?

2 Ansichten (letzte 30 Tage)
for eg-
i need this matrix to look like {1,9} {2,7} {3,8}.......
  3 Kommentare

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Image Analyst
Image Analyst am 14 Sep. 2018
Bearbeitet: Image Analyst am 14 Sep. 2018
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

Weitere Antworten (2)

Matt J
Matt J am 14 Sep. 2018
Bearbeitet: Matt J am 14 Sep. 2018
Acell=cellfun( @(c) c(:).', num2cell(A,3), 'uni',0 );

Image Analyst
Image Analyst am 14 Sep. 2018
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

Kategorien

Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by