matlab determine if cells array is a row

I have a data:

data = 

{1x6 cell}    {1x6 cell}

I want to know if data{2:end} is a row, so I used:

stop = 0;
for (k=2:length(data))
    if isrow(data{k})
         stop = 1;
    end
end

but, the function 'isrow' doesn't work for arguments of type 'cell'.

I read about it, and there is a function: 'cell2struct':

structArray = cell2struct(cellArray, fields, dim);

but I don't think that I will be able to use that, because I have to give 'fields' and 'dim' to this function.

Answers


I don't really see what the problem is here. This is what I get on R2010b:

>> data = {cell(1,6) cell(1,6) cell(3,6)}
data = 
    {1x6 cell}    {1x6 cell}    {3x6 cell}

>> isrow(data{2})
ans =
     1

>> isrow(data{3})
ans =
     0

Try to check it in another way:

  function bIsRow = isrow(x)
      bIsRow = (size(x,2) == numel(x));
  end

Try

if isrow(cell2mat(data{k}))

You can use the following code for isrow()

function Y = isrow(X)
%
% ISROW    True for row vectors.
%
%   Y = ISROW(X) returns logical 1 if X is a row vector, 0 otherwise.
%   ISROW returns 1 for scalars also.
%
%    See also: ISCOL.
%

if ndims(X)==2 & size(X,1)==1 & size(X,2)>=1
   Y = logical(1);
else
   Y = logical(0);
end

Source via MATLAB Central


Need Your Help

C++ Operator overload: stl sort on vector of my custom class

c++ sorting stl vector operator-overloading

I have a very basic class that is stored inside an STL Vector. I am trying to sort that vector, but am getting cryptic STL errors. Can someone assist?

css3 arrow with drop shadow

html css3

Hey currently I have this css to produce a css arrow but I cannot seem to get a drop shadow on it any ideas