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

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)

 Accepted Answer

tf = iscell(A);
if tf == 1
A =cell2mat(A)
end

2 Comments

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.
Thank you. I'll correct it.

Sign in to comment.

More Answers (0)

Categories

Products

Tags

Asked:

on 7 Jul 2015

Edited:

on 8 Jul 2015

Community Treasure Hunt

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

Start Hunting!