How to convert a 3x3xN matrix to a N element cell array?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Alon Rozen
am 21 Nov. 2016
Kommentiert: Alexandra Harkai
am 21 Nov. 2016
Hi all,
I have a three dimension matrix of 3x3xN, where N is a large number. I want to convert it to a N elements cell array in which every cell i contains the 3x3 matrix in the i'th position. I tried to work it out using the functions 'mat2cell' and 'num2cell' but couldn't understand how to do it. I read the help for these two functions but it didn't help me.
Can it be done?
Thanks,
Alon
0 Kommentare
Akzeptierte Antwort
Alexandra Harkai
am 21 Nov. 2016
Bearbeitet: Alexandra Harkai
am 21 Nov. 2016
% a is your 3*3*N array
c = mat2cell(a,3,3,ones(1,N));
c = c(:);
2 Kommentare
Alexandra Harkai
am 21 Nov. 2016
It does actually (ie. you first want something that contains 3*3*1 elements in each cell, so according to help you need to go for [3],[3],[1 1 ...]), but that doesn't mean one doesn't get it wrong for the first try. Trial an error :)
Weitere Antworten (1)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!