How to use convolution operator in matlab?
You are getting the error because image I is of class (data type) 'uint8', and the arguments to conv2 must be of class 'single' or 'double', i. e. floating point. You can get rid of the error by converting I to double.  The best way to do that is to call I = im2double(I), which will re-scale the pixel values to be between 0 and 1.

But looking at the big picture, you should not use conv2 at all, and use imfilter instead, which does take 'uint8' images.  Look at the help for it.  By default it does correlation, but it can also do convolution.