Filter löschen
Filter löschen

cell2mat of specific coulmns

2 Ansichten (letzte 30 Tage)
Mori
Mori am 24 Jul. 2016
Bearbeitet: Azzi Abdelmalek am 24 Jul. 2016
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?
  2 Kommentare
Azzi Abdelmalek
Azzi Abdelmalek am 24 Jul. 2016
The result should be 8x6 matrix instead of 6x8
Mori
Mori am 24 Jul. 2016
ok, got it

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Azzi Abdelmalek
Azzi Abdelmalek am 24 Jul. 2016
Bearbeitet: Azzi Abdelmalek am 24 Jul. 2016
A=arrayfun(@(x) randi(10,8,3),1:6,'un',0) % ----Example------
B=cell2mat(cellfun(@(x) x(:,3),A,'un',0))
  6 Kommentare
Mori
Mori am 24 Jul. 2016
I see, my file has a problem, cell 280 missing 1 raw.
Azzi Abdelmalek
Azzi Abdelmalek am 24 Jul. 2016
Bearbeitet: Azzi Abdelmalek am 24 Jul. 2016
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))

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Resizing and Reshaping Matrices 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!

Translated by