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 件のコメント

Walter Roberson
Walter Roberson 2011 年 6 月 7 日
"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.

サインインしてコメントする。

 採用された回答

Fangjun Jiang
Fangjun Jiang 2011 年 6 月 7 日

1 投票

>> 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 件のコメント

ramesh kumar sri
ramesh kumar sri 2011 年 6 月 8 日
Thanks for your answer....The problem is with stateflow, in comment promt it works well
ramesh kumar sri
ramesh kumar sri 2011 年 6 月 8 日
debug>> TotalGDCSec
TotalGDCSec =
31294405
debug>> TotalTCUSec
TotalTCUSec =
62251371
debug>> TotalGDCSec-TotalTCUSec
ans =
0
debug>> TotalTCUSec-TotalGDCSec
ans =
30956966
Walter Roberson
Walter Roberson 2011 年 6 月 8 日
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.
Fangjun Jiang
Fangjun Jiang 2011 年 6 月 8 日
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
ramesh kumar sri
ramesh kumar sri 2011 年 6 月 8 日
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..
ramesh kumar sri
ramesh kumar sri 2011 年 6 月 8 日
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