Hi, you can achieve this by using fi object
Cm = fi(rand(8,8), 1, 16);
Xm = fi(rand(8,8), 1, 16);
F1 = fimath('ProductMode','keepMSB',...
'ProductWordLength',16, ...
'SumMode', 'SpecifyPrecision',...
'SumWordLength',17,...
'SumFractionLength',14);
Cm.fimath = F1;
Tm = Cm*Xm;
you can compare you fixed-point result with floating-point reference result to check for numerical correctness and quantization error. you can adjust following "knobs" to minimize quantization errors,
- ProducMode
- SumFractionLength if SumMode is 'SpecifyPrecision'
- SumMode
- ProductFractionLength if ProductMode is 'SpecifyPrecision'
hope it helps.