cell2mat of specific coulmns
조회 수: 3 (최근 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?
댓글 수: 2
채택된 답변
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
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 Center 및 File Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!