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 Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by