to save different dimension cell to double

my code generates a cell p = cell
each cell have different number entries..
I wish to write all entries in all cells one after other in a double format///
any direction in this regard will be of great help

댓글 수: 3

KSSV
KSSV 2016년 12월 1일
Where you want to write?
Bhowmik.U
Bhowmik.U 2016년 12월 1일
Hello Sir,
I wish to write the values into an array of doubles...
soemhow
C_double = cellfun(@cell2mat,p,'un',0) ;
returns the error
Cell contents reference from a non-cell array object.
Error in cell2mat (line 37) if isnumeric(c{1}) ischar(c{1}) islogical(c{1}) isstruct(c{1})
KSSV
KSSV 2016년 12월 1일
편집: KSSV 2016년 12월 1일
Check what is size of p and what is class of p{1,1}? I think the elements of cell p are not cells.

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

 채택된 답변

KSSV
KSSV 2016년 12월 1일

0 개 추천

C_cell = cell(2) ;
for i =1:2
for j = 1:2
C_cell{i,j} = {rand(3)} ;
end
end
C_double = cellfun(@cell2mat,C_cell,'un',0) ;
C_cell
C_double

댓글 수: 4

Bhowmik.U
Bhowmik.U 2016년 12월 1일
actually my cell p look like this
some cells have single entries
some have multiple entries
I need to obtain and write all entries (single entryof one cell, followed by multiple entries of another cell one after other....)
Try this:
c = cell2mat(p(:)) ;
If any error, attach the cell as mat file.
Bhowmik.U
Bhowmik.U 2016년 12월 1일
Thanks a lot Sir for your help...you saved my day.
No words to express my gratitude!
KSSV
KSSV 2016년 12월 1일
You are welcome...

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Workspace Variables and MAT Files에 대해 자세히 알아보기

질문:

2016년 12월 1일

댓글:

2016년 12월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by