cell2mat conversion
Mostrar comentarios más antiguos
please help me to convert 1*28 cell in which each cell contains 10*25 size matrices.
i tried this
cell2mat(matrix)
it gives 10*7000 matrix
help me to convert it to double matrix
help me to solve this
Thanks in advance
3 comentarios
Twenty-eight cells each containing a 10x25 numeric array gives
>> 28*10*25
ans = 7000
seven thousand numeric elements. You request a numeric array with only twenty-eight numeric elements. What do you want to do with the other six-thousand, nine-hundred and seventy-two numeric elements?
Leela Sai Krishna
el 22 de Mayo de 2019
It is even less clear now. You removed any description of what you expect the result to be. Initially you said you wanted a 1x28 double vector as a result. As Stephen has already told you, the process you want for reducing your 10x25 matrix to a single number needs to be explained.
Respuestas (10)
cellfun(@(c) c(1), your_1x28_input)
Matt J
el 22 de Mayo de 2019
cellfun(@(c) mean(c(:)), your_1x28_input)
1 comentario
madhan ravi
el 22 de Mayo de 2019
cellfun(@(c) mean2(c), your_1x28_input)
Matt J
el 22 de Mayo de 2019
cellfun(@(c) std(c(:)), your_1x28_input)
1 comentario
madhan ravi
el 22 de Mayo de 2019
cellfun(@(x) sum(x(:)), yourcell)
Matt J
el 22 de Mayo de 2019
cellfun(@(c) sum(c(:)), your_1x28_input)
Matt J
el 22 de Mayo de 2019
cellfun(@(c) max(c(:)), your_1x28_input)
Matt J
el 22 de Mayo de 2019
cellfun(@(c) min(c(:)), your_1x28_input)
1 comentario
madhan ravi
el 22 de Mayo de 2019
cellfun(@(c) prod(c(:)), your_1x28_input)
Matt J
el 22 de Mayo de 2019
cellfun(@(c) var(sum(c,2)), your_1x28_input)
Matt J
el 22 de Mayo de 2019
ones(size( your_1x28_input))
1 comentario
madhan ravi
el 22 de Mayo de 2019
rand(size( your_1x28_input))
Jos (10584)
el 22 de Mayo de 2019
Do you want to convert the 1-by-28 cell array C, each cell holding a 10-by-25 double matrix to a 3D double array M of size 10-by-25-by-28?
M = cat(3, C{:})
4 comentarios
Leela Sai Krishna
el 22 de Mayo de 2019
Jos (10584)
el 22 de Mayo de 2019
I do not know what you mean by "store 28 cells (10*25) in matrix form"?
Can you give a smaller example (for instancem 2 cells (2*3) in matrix form)?
Leela Sai Krishna
el 22 de Mayo de 2019
Jos (10584)
el 22 de Mayo de 2019
Your question is still unclear. Can you give a complete example of the output?
C = {[1 2 3 ; 4 5 6] ; [11 12 13 ; 14 15 16]} % 1-by-2 cell array
% OUT = ....
Matt J
el 22 de Mayo de 2019
But is it possible to store 28 cells(10*25) in matrix form
I'm starting to think you mean this
[Matrix1,Matrix2,..., Matrix28] = deal(yourCell{:})
1 comentario
You might be right...
@Leela Sai Krishna: if you are trying get the contents of the cell array as 28 separate variables, then be aware that in general splitting up data makes it harder to work with. Most likely the best solution would be to leave your data in that cell array just as it is, where it can be trivially accessed using indexing.
Also note that using numbered variables (e.g. M1, M2, ... M28) is a sign that code is badly designed, and generally such names lead beginners into writing slow, complex, buggy code that is hard to debug.
Categorías
Más información sobre Data Type Conversion en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!