How do I convert a cell array to matrix whose dimensions are not equal?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Manoj
am 10 Feb. 2016
Kommentiert: Walter Roberson
am 15 Feb. 2016
mydata =
[195x1 double] [124x1 double] [1826x1 double] [2x1826 double] [195x124x1826 single]
5 Kommentare
Jan
am 11 Feb. 2016
I neither understand the meanig of the images, not the description "matrix form with different file names".
Geoff Hayes
am 11 Feb. 2016
Manoj - how should all of this data, from your cell array, be packaged into the matrix? What should the dimensions be for the matrix?
Akzeptierte Antwort
Walter Roberson
am 11 Feb. 2016
%using variable names from your posting, structure as in capture.JPG
md1 = mydata{1};
md2 = mydata{2};
md3 = mydata{3};
md4 = mydata{4};
md5 = mydata{5};
[X, Y, Z] = ndgrid(md1, md2, md3);
pointsize = 20;
scatter3(X(:), Y(:), Z(:), pointsize, md5(:));
%using variable names from data file.JPG
%the data is a mix of int16 and int32 and we need to make it all the same datatype to
%make it into a numeric matrix without risk that the wrong datatype would be used
temp = cellfun(@(M) int32(M.'), permute(B,[1 3 2]), 'Uniform', 0);
B30 = cell2mat( arrayfun(@(R) horzcat(temp{R,:}), 'Uniform', 0) );
The result of this, B30, would be a 30 x 10666 numeric array, in which each row is formed by concatenating together the 2446 x 1, 2532 x 1, 2651 x 1, 3037 x 1 as one piece and making that a row.
3 Kommentare
Walter Roberson
am 15 Feb. 2016
You have changed the size of your data in mydata. Please show the current summary of mydata and also of B.
The line
B30 = cell2mat( arrayfun(@(R) horzcat(temp{R,:}), 'Uniform', 0) );
should be
B30 = cell2mat( arrayfun(@(R) horzcat(temp{R,:}), 1:size(temp,1), 'Uniform', 0) );
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Operators and Elementary Operations 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!