How to figure out if an array is ordinary or cell?

조회 수: 1 (최근 30일)
Sam136
Sam136 2015년 7월 7일
편집: bio lim 2015년 7월 8일
In my code, variable (A) can be either an ordinary array or cell array. How can I do following
If (A) is an ordinary array then do nothing If (A) is a cell array then cell2mat(A)

채택된 답변

bio lim
bio lim 2015년 7월 7일
편집: bio lim 2015년 7월 8일
tf = iscell(A);
if tf == 1
A =cell2mat(A)
end
  댓글 수: 2
Steven Lord
Steven Lord 2015년 7월 7일
Two comments:
  1. You don't need to use == 1 here.
  2. You need to return an output argument from CELL2MAT, otherwise you're making a matrix from the cell array then throwing that matrix away.
bio lim
bio lim 2015년 7월 8일
Thank you. I'll correct it.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by