I am getting this error in MatLab when trying to fill in an array. MatLab is saying that the assignment B(j, 1) = z(z-counter)
contains a negative or non integer value. However when I look at the variables values in the workspace after trying to execute the code.
j =1, counter =1, z =1
for j= 1:1:totalSizeOfMatrix
if( j <= totalNumberInBottom)
if( mod(j, lengthOfBottomRow) == 1)
counter= counter +1;
end
z = mod(j,lengthOfBottomRow);
B(j,1) = z(z-counter);
end
if( j > totalNumberInBottom && j <= totalNumberNotInTop)
if( mod(j, lengthOfSecondRow) == 1)
counter= counter +1;
end
z = mod(j,lengthOfSecondRow);
B(j,1) = z(z-counter);
end
if( j > totalNumberInBottom)
if( mod(j, lengthOfTopRow) == 1)
counter= counter +1;
end
z = mod(j,lengthOfTopRow);
B(j,1) = z(z-counter);
end
end