fork download
  1. function m = g(m, n)
  2. m = [repmat('*', 1, numel(m)); m];
  3. m(:, n) = flip(m(:, n));
  4. end
  5. g('def', 2)
  6. g('def', [1 3])
  7.  
  8. h = @(m, n) cell2mat(arrayfun(@(c, i) {['*'; c] [c; '*']}(1 + any(i == n)), m, 1:numel(m)));
  9. h('ghi', 2)
  10. h('ghi', [1 3])
Success #stdin #stdout 0.25s 411840KB
stdin
Standard input is empty
stdout
ans =

*e*
d*f

ans =

d*f
*e*

ans =

*h*
g*i

ans =

g*i
*h*