필터 지우기
필터 지우기

How to collect information of different cells in a column vector

조회 수: 2 (최근 30일)
Vishal Sharma
Vishal Sharma 2017년 1월 25일
답변: Guillaume 2017년 1월 25일
I have a cell array x{n,j}
<3x8 double>
<8x9 double>
<5x9 double>
<2x8 double>
<8x9 double>
<5x9 double>
<2x8 double>
<8x9 double>
<4x9 double>
<2x8 double>
<8x9 double>
<3x9 double>
The information stored in various cells is to be compiled in one column vector
n is number of iterations. a=5
This code is not working
I want to collect first column of each cell into one vector
n=1:a
for j=1:columns;
[row,col]=size([x{n,j}]);
p=x{n,j}(2:row,1);
end
  댓글 수: 1
Jan
Jan 2017년 1월 25일
Please post the input in valid Matlab syntax. I cannot guess reliably, what "array x{n,j} double double double ..." exactly means. What is the purpose of the variable "a"? You code overwrites "p" in each iteration, but I cannot guess, what you want to get instead.

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

답변 (2개)

Walter Roberson
Walter Roberson 2017년 1월 25일
temp = cellfun(@(M) M(:,1), 'Uniform', 0);
output = vertcat(temp{:});

Guillaume
Guillaume 2017년 1월 25일
As Jan says, it's difficult to understand what you want when you don't use valid matlab syntax for your examples. An example constructing a small cell array and showing the exact desired output would be a lot more useful.
At a guess,
column1 = cellfun(@(m) m(:, 1), x, 'UniformOutput', false);
column1 = vertcat(column1{:});

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by