valIdeal =
Behavioral Requirements are Key
The key question is whether the system meets its behavioral requirements.
I applied Data Type Override to your model
set_param(bdroot,'DataTypeOverride','Double')
to see the "luxury" simulation behavior using double precision floating point.
I then turned off Data Type Override
set_param(bdroot,'DataTypeOverride','UseLocalSettings')
to see the current fixed-point behavior.
Just from glancing at your Scope blocks, the responses looked pretty similar. But that's superficial.
I suggest you create tests to exercise your model and prove that it meets behavior constraints in doubles.
Write scripts that test the simulation response to show that behavior requirements are met.
The scripts could be informal or use the MATLAB unit testing tools. Key thing is that running the script should clearly indicate if the model meets the behavior requirements.
Then turn on the fixed-point data types and re-run your scripts on the model. Does it still pass the behavioral requirements? If yes, you're done. If not, you could explore where the model is most numerically sensitive and explore using bigger fixed-point data types there.
Precision Loss is Expected
Parameter precison loss messages like the following are to be expected.
"The original value of the parameter, 0.7071067811865475, cannot be represented exactly using the run-time data type sfix16_En15. The value is quantized to 0.70709228515625. Quantization error occurred with an absolute difference of 1.4496030297461715e-5 and a relative difference of 0.00205004826472416%."
It looks like the "ideal" value being used is sqrt(2)/2.
Representing that value even double precision floating-point will involve precision loss.
format long g
valIdeal = sqrt( sym(2) ) / 2
valDouble = double(valIdeal)
errDouble = double( sym(valDouble,'f') - valIdeal )
Here are several fixed-point example using best precision scaling with various word lengths.
valFi64 = fi([],0,64,'Value',char(vpa(valIdeal,50)));
wlv = [inf, 64, 53, 32, 24, 16, 8:-1:1];
for wl = wlv
if isinf(wl)
fprintf("valIdeal = %s...\n",char(vpa(valIdeal,80)))
continue
end
fiCurrent = fi(valFi64,0,wl);
if wl == 53
s2 = " Same accuracy as double";
elseif wl == 24
s2 = " Same accuracy as single";
else
s2 = "";
end
fprintf("valFi%02d = %-51s %s\n",wl,fiCurrent.Value,s2)
end
The accuracy at 16 bits is pretty good. It's unlikely something you need to worry about. You could set the parameter precision loss diagnostic to None, or you could review each warning, and if OK, then click the suppress link in the Diagnostic Viewer.