Division in stateflow is showing only integer part
1 回表示 (過去 30 日間)
古いコメントを表示
I am trying to do a simple division operation in stateflow like a=5/2 but the output is coming to 2 instead of 2.5 The data type of a is double. Its rounding the decimal digits and giving me only the integer part. Pls help
1 件のコメント
回答 (3 件)
Vishal Rane
2013 年 3 月 15 日
編集済み: Vishal Rane
2013 年 3 月 15 日
I believe typecasting both dividend and divisor as double should do the job.
{
a = double(5)/double(2);
}
Not sure whether this the usual approach.
chaitanya balaga
2019 年 11 月 20 日
編集済み: chaitanya balaga
2019 年 11 月 20 日
Instead, you can try the following assignment, a:=5/2;
This overrides the floor(a/b) behaviour in stateflow and gives you the desired result which is entirely dependent on the datatype of a. In this case you will get a = 2.5
0 件のコメント
参考
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!