MATLAB: How to create the definite cycle and to display the result of a cycle in a single matrix of a definite size

cycleMATLABmatrix manipulationoutputrepresentsparse matrix

Hello, I have cycle to represents b as matrix.
m=[];
b=[4];
for i=0:6 %Creating cycle
b=circshift(b,[0,i]); %Shift b
z=zeros(1,7,'int8'); %Create zeros string to represents b as 0 0 0...b..0
if b==0 %If b=0 then z=1 0 0...0
z(1)=1;
m=[m; z];
else
z(b)=b;
b=mod(b,7);
b=b+1;
m=[m; z];
end
end
ANSWER:
m =
0 0 0 4 0 0 0
0 0 0 0 5 0 0
0 0 0 0 0 6 0
0 0 0 0 0 0 7
1 0 0 0 0 0 0
0 2 0 0 0 0 0
0 0 3 0 0 0 0
I need to create the cycle for represent matrix b, for example, b=[1 2; 5 6] . In the form matrix m dimension 7*2×7*2=14×14. Only necessary that each value of b displayed by its matrix m For example, for b=[1 2; 3 4], I need create the following m:
m =
1 0 0 0 0 0 0 0 2 0 0 0 0 0
0 2 0 0 0 0 0 0 0 3 0 0 0 0
0 0 3 0 0 0 0 0 0 0 4 0 0 0
0 0 0 4 0 0 0 0 0 0 0 5 0 0
0 0 0 0 5 0 0 0 0 0 0 0 6 0
0 0 0 0 0 6 0 0 0 0 0 0 0 7
0 0 0 0 0 0 7 1 0 0 0 0 0 0
0 0 0 0 5 0 0 0 0 0 0 0 6 0
0 0 0 0 0 6 0 0 0 0 0 0 0 7
0 0 0 0 0 0 7 1 0 0 0 0 0 0
1 0 0 0 0 0 0 0 2 0 0 0 0 0
0 2 0 0 0 0 0 0 0 3 0 0 0 0
0 0 3 0 0 0 0 0 0 0 4 0 0 0
0 0 0 4 0 0 0 0 0 0 0 5 0 0
Help me, please!

Best Answer

A = eye(7).*repmat(1:7,7,1);
[x,y] = size(b);
m = zeros(7*x,7*y);
for i = 1:x
for j = 1:y
if (b(i,j) == 0)
m((i-1)*7+1:i*7,(j-1)*7+1:j*7) = 0;
else
m((i-1)*7+1:i*7,(j-1)*7+1:j*7) = circshift(A,(-1)*b(i,j)+1);
end
end
end
This will do it.