for your convenience MATLAB has a built in general crc generator on it's communication blockset. Try search using MATLAB Help..
if you don't installed MATLAB HELP anyway here is a link on it
_http://web.unbc.ca/~robert/matlab/toolbox/commblks/ref/generalcrcgenerator.html