cell2mat of specific coulmns

2 次查看(过去 30 天)
I have a cell called A, with 6*1 cell, each cell has 8*3 doubles. How I create matrix B with 6*8 size which each column of B includes 3rd column of each cell of A?

采纳的回答

Azzi Abdelmalek
Azzi Abdelmalek 2016-7-24
编辑:Azzi Abdelmalek 2016-7-24
A=arrayfun(@(x) randi(10,8,3),1:6,'un',0) % ----Example------
B=cell2mat(cellfun(@(x) x(:,3),A,'un',0))
  6 个评论
Mori
Mori 2016-7-24
I see, my file has a problem, cell 280 missing 1 raw.
Azzi Abdelmalek
Azzi Abdelmalek 2016-7-24
编辑:Azzi Abdelmalek 2016-7-24
You can complete the last row with nan. look at this example
% -------Example------------------
A=arrayfun(@(x) randi(10,8,3),(1:6),'un',0)
A{5}=randi(10,7,3)
%----------The code-------------------------
A{5}(end+1,:)=nan(1,3) % complete the last row of the fifth cell with nan
B=cell2mat(cellfun(@(x) x(:,3),A,'un',0))

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by