MatLab 2012b sum block with signed/unsigned numbers

조회 수: 3(최근 30일)
Lucas
Lucas 2014년 8월 7일
댓글: Yu Jiang 2014년 8월 11일
If I have a sum block that's taking 2 constants in, one signed the other unsigned, and I add them together I do not get the result that I expect in the picture below: OutDataTypeStr for the sum block is Inherit: Inherit via internal rule, expected is 475.
I noticed that MatLab created a new data type, sfx32_E1, and that the number was 1 off from what I expected it to be. When I changed the sum block to output as an int32, I got the result that I expected it to be.
So I was wondering why the results were different and what that data type that's outting in the first picture means. I'm going to assume that this is the same for the other math operation blocks in MatLab? Thanks!
  댓글 수: 1
Lucas
Lucas 2014년 8월 8일
One bump to see if anyone knows what is going on here.

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

채택된 답변

Yu Jiang
Yu Jiang 2014년 8월 8일
편집: Yu Jiang 2014년 8월 8일
Before the model is executed, SIMULINK will try to figure out what is the output datatype of the Add Block. Since the Display is not datatype-dependent, and the two input data types are different, SIMULINK seems to be "confused" and ends up with generating the new datatype sfix32_E1.
  댓글 수: 2
Yu Jiang
Yu Jiang 2014년 8월 11일
Hi Lucas
I am not sure how exactly the internal rule works and why it is one less. You can find its description here.
From my point of view, this is a side effect when SIMULINK tries to use the internal rule without knowing what the expect output datatype should be. In this case, the difference happens to be one, but it may be something else in other cases.
-Yu

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

추가 답변(0개)

Community Treasure Hunt

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

Start Hunting!

Translated by