필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

is there any process to convert cell type array to numarical array?

조회 수: 1 (최근 30일)
partha das
partha das 2011년 7월 6일
마감: MATLAB Answer Bot 2021년 8월 20일
is there any process to convert a cell type array having 1 column to a matrix where the rows of cell type array will be the rows of the matrix and the component of the cell type array have different no of 1 row component in every column. 1 want that other column where the values does not have should consist of zero. please inform me. thank you in advance.
  댓글 수: 1
zohar
zohar 2011년 7월 6일
Give example how the data look like and how do you want it to be .

답변 (1개)

Titus Edelhofer
Titus Edelhofer 2011년 7월 6일
Hi,
if I understand correctly, the answer is no. But it would not be difficult to do:
Acell = {[1 2 3]; [1 2]; [1 2 3 4]};
columns = max(cellfun(@length, Acell));
A = zeros(length(Acell), columns);
for i=1:length(Acell)
A(i, 1:length(Acell{i})) = Acell{i};
end
Titus
  댓글 수: 4
Titus Edelhofer
Titus Edelhofer 2011년 7월 6일
Hi Jan,
I understood "where the values does not have should consist of zero" that OP wants to have zeros where no values are given. Instead of zeros of course any other value can be used (e.g. nan).
Titus
Sean de Wolski
Sean de Wolski 2011년 7월 6일
'prodofsize' is a good one!
Even 7ishx faster than numel.

이 질문은 마감되었습니다.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by