cell2mat conversion

조회 수: 1 (최근 30일)
Leela Sai Krishna
Leela Sai Krishna 2019년 5월 22일
편집: Stephen23 2019년 5월 23일
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
Leela Sai Krishna
Leela Sai Krishna 2019년 5월 22일
I am not clear in previous question.
I just edited my question.
Thanks
Catalytic
Catalytic 2019년 5월 22일
편집: Catalytic 2019년 5월 22일
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.

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

답변 (10개)

Matt J
Matt J 2019년 5월 22일
편집: Matt J 2019년 5월 22일
cellfun(@(c) c(1), your_1x28_input)

Matt J
Matt J 2019년 5월 22일
cellfun(@(c) mean(c(:)), your_1x28_input)
  댓글 수: 1
madhan ravi
madhan ravi 2019년 5월 22일
cellfun(@(c) mean2(c), your_1x28_input)

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


Matt J
Matt J 2019년 5월 22일
cellfun(@(c) std(c(:)), your_1x28_input)
  댓글 수: 1
madhan ravi
madhan ravi 2019년 5월 22일
cellfun(@(x) sum(x(:)), yourcell)

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


Matt J
Matt J 2019년 5월 22일
cellfun(@(c) sum(c(:)), your_1x28_input)

Matt J
Matt J 2019년 5월 22일
cellfun(@(c) max(c(:)), your_1x28_input)

Matt J
Matt J 2019년 5월 22일
cellfun(@(c) min(c(:)), your_1x28_input)
  댓글 수: 1
madhan ravi
madhan ravi 2019년 5월 22일
cellfun(@(c) prod(c(:)), your_1x28_input)

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


Matt J
Matt J 2019년 5월 22일
cellfun(@(c) var(sum(c,2)), your_1x28_input)

Matt J
Matt J 2019년 5월 22일
ones(size( your_1x28_input))
  댓글 수: 1
madhan ravi
madhan ravi 2019년 5월 22일
rand(size( your_1x28_input))

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


Jos (10584)
Jos (10584) 2019년 5월 22일
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
Leela Sai Krishna
Leela Sai Krishna 2019년 5월 22일
i have 1*2 cell array
in which each cell contains 2*3 matrix
i.e
cell1 cell2
2*3 2*3
i am trying to store it in 2 matrices
Jos (10584)
Jos (10584) 2019년 5월 22일
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
Matt J 2019년 5월 22일
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
Stephen23
Stephen23 2019년 5월 23일
편집: Stephen23 2019년 5월 23일
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.

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by