function s = e11v3(m) % s = e11v3(m): return a $m$-by-$2m$ string matrix $s$ with % + $*$s on the border (left, right, top, and bottom edges) % + $\$s on the diagonal, except for on the border % (the *diagonal* of a matrix = all valid positions (i,i) in the matrix) % + $-$s below the diagonal, except for on the border % + $+$s on the boundary, $@$s in the interior, and $c$ at the center of % a disk of radius $round(m*.35)$ and center $(round(m*1.5),round(m/2))$ % version where $y$s are generated from $x$s n = 2*m; % width of $s$ % [3/14] fixed typo below, where $xc<-->yc$ xc = round(m*1.5); yc = round(m/2); % (yc,xc) = center of disk r = round(m*.35); % radius of disk % note: deleted definition of coordinate matrices $x$,$y$ from skeleton code s(m,n) = ' '; % make $s$ large enough s(:,:) = 'o'; % fill each element with $'o'$ % place $-$s below diagonal: y > x for x = 1:n for y = x+1:m; s(y,x) = '-'; end end % place $\$s on diagonal: y = x for x = 1:n % or just $1:m$ and omit the conditional test below if x <= m y = x; s(y,x) = '\'; end end % place $*$s on border: x = 1, x = n, y = 1, y = m % left edge x = 1; for y = 0*x + (1:m) % or just $1:m$ s(y,x) = '*'; end % right edge x = n; for y = 0*x + (1:m) % or just $1:m$ s(y,x) = '*'; end % top and bottom edges for x = 1:n % top edge y = 0*x + 1; % or just $1$ s(y,x) = '*'; % bottom edge y = 0*x + m; % or just $m$ s(y,x) = '*'; end warning('disk not done using this approach')