Providing Maximum Value as Initial Value for Single Precision Signal Causes Error due to Quantization

15 vues (au cours des 30 derniers jours)
I have a model which has an input signal with data type "single". This signal has the initial value which is same as maximum value. (10.3 for this case). When I evaluate the model, I get the error stating that quantized initial value is greater than maximum value.
  • Below is screenshot of definition of signal and error I get during model update.
I believe the cause of the error is that maximum value is evaluated with data type "double" while initial value is evaluated with data type "single", and 10.3 with single precision is greater than 10.3 with double precision as shown below.
As data dictionary only accepts finite real double scalar value for maximum and minimum value, I was not able to find good solution for the problem.
  • How can I work around this problem?
  • Is there any method to set maximum and minimum value of the signal with datatype single?
I have attached sample model and associated data dictionary which reproduces the problem. The problem happens for "sample_input" signal.

Réponse acceptée

Fangjun Jiang
Fangjun Jiang le 1 Nov 2018
I had similar issues with this. I have requested the Mathworks to do an enhancement but have not seen it in place yet.
The problem arises when casting a number from double to single. The "precision loss" occurred and Simulink reports it as warning or error. It is true that the "precision loss" could happen but I think the software should give an option whether the user wants to ignore the double-to-single type cast precision loss.
What version of MATLAB are you using? The message seems to be different than what I saw in several versions of MATLAB/Simulink. Typically, you can go to Simulink configuration parameters, Diagnostics, Data Validity, Parameters, change the setting for "Detect precision loss". If you set it as "warning" or "none", you could pass the model update with or without even the warning messages.
You could also try to set the Initial value as single(10.3). In my case, the warning disappeared by doing this.
  4 commentaires
Kazumi Malhan
Kazumi Malhan le 1 Nov 2018
Thank you for quick response. I will contact MathWorks tech support.
Kazumi Malhan
Kazumi Malhan le 1 Nov 2018
I got the response from MathWorks that this problem is resolved in R2017a ( Link to release note ). For R2016b, the workaround is what Fangjun has suggested.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Event Functions dans Help Center et File Exchange

Produits


Version

R2016b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by