I have this code for CRC code in MATLAB, msg
is the data and poly
is the generator function.
msg=[1 0 1 1 0 0 1 0 1 ];
poly=[1 0 1 1];
[M, N]=size(poly);
mseg=[msg zeros(1,N-1)];
[q, r]=deconv(mseg,poly);
r=abs(r);
for i=1:length(r)
a=r(i);
if ( mod(a,2)== 0 )
r(i)=0;
else
r(i)=1;
end end
crc=r(length(msg)+1:end) frame = bitor(mseg,r)
It works well but I want to do it for random msg
with size of 7.
I used this but it has error.
msg = randi([0, 1], 7,1);
The error is:
Error using horzcat Dimensions of matrices being concatenated are not consistent.
please help me with this problem.