cell2str.m 475 B

12345678910111213141516171819202122
  1. function f = cell2str(m)
  2. % function f = cell2str(m)
  3. %
  4. % <m> is a 2D cell matrix with elements that are number-matrices or strings.
  5. %
  6. % return the string that can be evaluated to obtain <m>.
  7. %
  8. % example:
  9. % a = {1 [5 6 7]; ':' 'df'};
  10. % isequal(cell2str(a),'{ 1 [5 6 7]; '':'' ''df'';}')
  11. % isequal(a,eval(cell2str(a)))
  12. % do it row by row
  13. f = '{';
  14. for p=1:size(m,1) % POTENTIALLY SLOW
  15. for q=1:size(m,2)
  16. f = [f ' ' mat2str(m{p,q})];
  17. end
  18. f = [f ';'];
  19. end
  20. f = [f '}'];