Howto allow overflow for angular data types in Simulink

3 visualizaciones (últimos 30 días)
Martin Otzen
Martin Otzen el 1 de Abr. de 2016
Comentada: Martin Otzen el 5 de Abr. de 2016
Question: How do I create a summation (or product) block in Simulink with angles as input where it will not warn about overflow during simulation?
I will be happy if I can disable it based on the datatype, but can also use a solution that will disable the warning for this specific summation block.
--
Background: In our models we use a lot of fixed point, this gives some hassle, but one of the thing you get for free here is the handling of angles, where angle wrap at 360 deg. i.e. 350 deg + 50 deg = 40 deg (not 400), by setting the scaling of the angletype in fixed point to overflow at 360 deg. This handling is done in no time by the type, as oposed to an algorithm like this temp = 350 + 50 if temp > 360 then temp = temp - 360
All good, but coming from the software dep. we have a strict policy of creating code/models with zero warnings ( just disabling the warnings globally is not allowed ). When I simulate my model that includes a summation of two angles, and the overflow is intended, I get a warning
I cannot just disable this warning globally for two reasons.
  1. I need to be warned if this happens for non-angular types.
  2. It is strictly against company rules.
--
NB: Sorry for cross posting to newsgruop, I think it was the wrong place, therefore repost here.

Respuestas (1)

Jeevan Joishi
Jeevan Joishi el 5 de Abr. de 2016
I am answering this more from your 'Background' section in the question. You can use switch block to construct different definitions for each of your data types. And then for each value of angular type, you can warp the values using 'mod' function in MATLAB. An example of the switch case is defined below -
function mySwitch(data)
classOfX = class(data);
switch classOfX
case 'double'
disp('The data is of type double');
case 'char'
disp('The data is of type char');
otherwise
disp('No predefined data type found');
end
end
  1 comentario
Martin Otzen
Martin Otzen el 5 de Abr. de 2016
Thanks for the answer, but my models is in Simulink.
I realized that this was not clear from my question, and have now edited it to mere more clear.

Iniciar sesión para comentar.

Categorías

Más información sobre General Applications en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by