Howto allow overflow for angular data types in Simulink
5 views (last 30 days)
Show older comments
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.
- I need to be warned if this happens for non-angular types.
- It is strictly against company rules.
--
NB: Sorry for cross posting to newsgruop, I think it was the wrong place, therefore repost here.
0 Comments
Answers (1)
Jeevan Joishi
on 5 Apr 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
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!