フィルターのクリア

Is it an integer value?

3 ビュー (過去 30 日間)
Sneha P S
Sneha P S 2018 年 4 月 6 日
コメント済み: Sneha P S 2018 年 4 月 11 日
1.7008e+05. IS this value considers as an integer in matlab.I found such values and when performing bitxor operation there occurs some error. So i doubted whether those value are the problem. Please help me with this.

採用された回答

Birdman
Birdman 2018 年 4 月 6 日
編集済み: Birdman 2018 年 4 月 6 日
Use isinteger to test whether it is integer or not:
isinteger(1.7008e+05)
ıt will give logical 0, which means it is not integer because MATLAB stores this number as double by default unless you define otherwise. For instance if you define as follows
int32(1.7008e+05)
you will know that it is integer.
  2 件のコメント
Sneha P S
Sneha P S 2018 年 4 月 6 日
Ok thankyou. But i had some values of these kind in one of my vector. So how can i change them to integers. That is, the entire vector of size 1x65536
Birdman
Birdman 2018 年 4 月 6 日
Consider you store them in A:
int32(A)
Note that even if you change one element's data type to integer, entire array will be defined as that integer type, therefore it will be better if you just convert the entire array to integer.

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

その他の回答 (1 件)

Steven Lord
Steven Lord 2018 年 4 月 6 日
The isinteger function checks if the class of the value is one of the eight integer types, not if the value is an integer value.
>> isinteger(1)
ans =
logical
0
The number 1 is stored by default in MATLAB as a double, so that's correct.
One way of checking the value is to use round.
>> A = [1 pi 5.5 17 -3];
>> A == round(A)
ans =
1×5 logical array
1 0 0 1 1
  1 件のコメント
Sneha P S
Sneha P S 2018 年 4 月 11 日
Thank you

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

カテゴリ

Help Center および File ExchangeNumeric Types についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by