how can i put value of cell in vector?
조회 수: 2 (최근 30일)
이전 댓글 표시
this error appear during the run of my program
"Cell contents reference from a non-cell array object."cell
U=[ ]
S={1 ,2 ,3}
for i=1:numel(S)
U=[U S{i}];
end
U = unique(U,'first');
댓글 수: 0
채택된 답변
Star Strider
2019년 11월 8일
Two options that come quickly to mind:
S={1 ,2 ,3};
U = [S{:}]
U = cell2mat(S)
Obviously these only work if the cell contents can be appropriately concatenated. If they cannot be, it is best to leave the cell array as a cell array, and address its contents as needed.
댓글 수: 2
Star Strider
2019년 11월 8일
The code you posted runs without error in R2019b, as does the code I posted.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Cell Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!