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

1 次查看(过去 30 天)
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.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by