fork download
  1. function f877(s)
  2. if isempty(s), return, end
  3. rows = [0 cumsum(s(1:end - 1) == sprintf('\n'))];
  4. cols = cell2mat(arrayfun(@(r) {0:sum(rows == r) - 1}, unique(rows)));
  5. pccr = @(c, col, row) fprintf({'' '[%c, %d, %d]\n'}{~isspace(c) + 1}, c, col, row);
  6. arrayfun(pccr, s, cols, rows);
  7. end
  8. f877(sprintf('a b c\n\nd'))
  9.  
Success #stdin #stdout 0.26s 411712KB
stdin
Standard input is empty
stdout
[a, 0, 0]
[b, 2, 0]
[c, 4, 0]
[d, 0, 2]