You will have to write your own code for this.
A = zeros(3,6);
[m,n] = size(A);
top = 1;
bottom = m;
left = 1;
right = n;
value = 1;
while true
if left>right
break;
end
for i = left:right
A(top,i) = value;
value = value + 1;
end
top = top + 1;
if top>bottom
break;
end
for i = top:bottom
A(i,right) = value;
value = value + 1;
end
right = right - 1;
if left>right
break;
end
for i = right:-1:left
A(bottom,i) = value;
value = value + 1;
end
bottom = bottom - 1;
if top>bottom
break;
end
for i = bottom:-1:top
A(i,left) = value;
value = value + 1;
end
left = left + 1;
end
A
Best Answer