Warning: Integer operands are required for colon operator when used as index
What does it mean? What should I do?
thanks
A) Means can't have _non_-integer subscripts for arrays.
B) Use an integer or round the float to an integer...
Perhaps show your work???
--
Which element of an array or vector is element 3.276?
John
I also want to kown...
When you index into a variable:
x = 1:10;
with an expression involving a colon:
x(1:5)
the elements generated by that colon operator should contain only integer
values; if it doesn't, you will receive that warning. For example:
x(1.5:1:5.5)
since 1.5:1:5.5 => [1.5 2.5 3.5 4.5 5.5] and none of those are integer
values, you will receive this warning.
--
Steve Lord
sl...@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
[x,y] = ginput(2)
size(Pic)
A = Pic(y(1):y(2),x(1):x(2),:);
Ab=A(:,:,3);
I am trying to take an image, convert it to RGB, display it, click an important area, make a new 3d matrix with the selected part of the image, zoom in, and then take only the blue layer and view it, and perform some calculations on the matrix as well. The g-input results are not integers, but I am not entirely sure what I should change about this. Also, currently my function is working, it just gives me this warning.
Thanks in advance.
-Jeff
The function ginput returns x and y coordinate values, which are unlikely to be integers. So the line A = Pic(y(1):y(2),x(1):x(2),:); is generating this error.
On a separate note, the line size(Pic) does nothing if you don't store that data somewhere, e.g. [m,n]=size(Pic).