I have written a MATLAB code that works okay but I want to write it in a more efficient way (I don't want to repeat myself and I want to make it dry).
At first I create a matrix of ones (28*8) and then I want to change some of its elements to minus ones.
Here is the code:
a=ones(28,8);
for i=1:7
j=1;
a(i,j)=-1;
end
for i=8:13
j=2;
a(i,j)=-1;
end
for i=14:18
j=3;
a(i,j)=-1;
end
for i=19:22
j=4;
a(i,j)=-1;
end
for i=23:25
j=5;
a(i,j)=-1;
end
for i=26:27
j=6;
a(i,j)=-1;
end
for i=28:28
j=7;
a(i,j)=-1;
end