Howto allow overflow for angular data types in Simulink

조회 수: 2 (최근 30일)
Martin Otzen
Martin Otzen 2016년 4월 1일
댓글: Martin Otzen 2016년 4월 5일
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.

답변 (1개)

Jeevan Joishi
Jeevan Joishi 2016년 4월 5일
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
Martin Otzen
Martin Otzen 2016년 4월 5일
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Simulink에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by