function s = e11v4(m) % s = e11v4(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 we loop over all positions and test a condition to see % if we care about that position 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 y = 1:m for x = 1:n if y > x s(y,x) = '-'; end end end % place $\$s on diagonal: y = x for y = 1:m for x = 1:n if y == x s(y,x) = '\'; end end end % place $*$s on border: x = 1, x = n, y = 1, y = m for y = 1:m for x = 1:n if x == 1 | x == n | y == 1 | y == m s(y,x) = '*'; end end end % place $@$s inside disk: d < r for y = 1:m for x = 1:n d = sqrt((x-xc)^2 + (y-yc)^2); if d < r s(y,x) = '@'; end end end % place $+$s on disk: r - .5 < d < r + .5 for y = 1:m for x = 1:n d = sqrt((x-xc)^2 + (y-yc)^2); if r - .5 < d & d < r + .5 s(y,x) = '+'; end end end % place $c$ at center of disk (done for you:) s(yc, xc) = 'c';