Datatype not supported by stateflow data: Data overflow

In Stateflow flow graph. I have mentioned a statement
Difference = data1 - data2;
I have assumed data types for this variable as follows
Difference - int32 - local
data1 - int32 - local
data2 -int32 - local
During run time data1 takes 86458 and data2 takes 5381838. while debugging it shows me a error: data overflow...
Kindly Please anyone help me out in solving this issue
Thanks in advance...:)

1 个评论

"I have assumed data types" -- but has Stateflow assumed the same data types? The error you are seeing could happen if Stateflow was using unsigned data types such as uint32.

请先登录,再进行评论。

 采纳的回答

>> data1=int32(86458 )
data1 =
86458
>> data2=int32(5381838)
data2 =
5381838
>> Difference = data1 - data2
Difference =
-5295380
It seems no problem in Matlab. Are you sure the error is caused by this? Could you step through Stateflow to see when the error occured?

6 个评论

Thanks for your answer....The problem is with stateflow, in comment promt it works well
debug>> TotalGDCSec
TotalGDCSec =
31294405
debug>> TotalTCUSec
TotalTCUSec =
62251371
debug>> TotalGDCSec-TotalTCUSec
ans =
0
debug>> TotalTCUSec-TotalGDCSec
ans =
30956966
That is exactly the behavior that one would see if the values were unsigned integers: unsigned integers "underflow" to 0 when you attempt to store a negative number in to them.
Walter might be right. Are you sure you declare those variables as int32, not as uint32?
>> data1=uint32(86458 )
data1 =
86458
>> data2=uint32(5381838)
data2 =
5381838
>> data2-data1
ans =
5295380
>> data1-data2
ans =
0
Thanks for your answer, The problem is solved. The problem is i have taken difference to be int32, but data1 and data2 to be uint32. But in this case we need all data to be same datatype..
Thanks a lot Fangjun Jiang & Walter Roberson

请先登录,再进行评论。

更多回答(0 个)

类别

在 帮助中心 和 File Exchange 中查找有关 Simulink Functions 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by