% CELLSTD Do std on all elements of a cell array
% s = cellstd(cellarray)

function s = cellstd(cellarray)

if length(size(cellarray))>2
   error('This only works for cell arrays up to 2D');
end

if iscell(cellarray{1,1})
    for i=1:size(cellarray,1)
        for j=1:size(cellarray,2)
            s{i,j} = cellstd(cellarray{i,j});
        end
    end
    return;
end

for i=1:size(cellarray,1)
 for j=1:size(cellarray,2)
      thestd = std(cellarray{i,j});
      if length(thestd)==1
 	s(i,j) = thestd;
      else
	s{i,j} = thestd;
      end
 end
end
