MATLAB: Subscript indices must either be real positive

for loopindexingMATLABmatrix

Hi it is a common error, yes I saw the other Q/A here, but still could not figure it out. the matrix indices cannot be zero, but I have values in the matrix are fractions 0.1,0.2,0.3etc, is that the issue?
I want to extract the (x,y) coordinates of the points on the boundary of the rectangular geometry as illustrated in the attached and save them in a matrix to use them later in an equation for each point.
first I tried to extract them for each side. I used the following procedure but stopped after a few points
for r=0:0.1:2
mat(r*10+1,:)=[1 r]
end
the error was
Subscript indices must either be real positive integers or logicals
Thanks

Best Answer

for r=0:0.1:2
mat(fix(r*10+1),:)=[1 r] % Considering only integer using *fix*
end