How do I differentiate between integer and floating point numbers in a double array?

2 次查看(过去 30 天)
My requirement is to import data from Excel which has both integer and floating point numbers. For example, 1 and 2.5 I want to differentiate between them. But the Excel import coverts all numeric data into 'double' which is floating point by default.
Any help in this regard is appreciated! Thanks!

采纳的回答

José-Luis
José-Luis 2014-1-15
is_integer = your_data == floor(your_data);
  2 个评论
Shubha
Shubha 2014-1-15
isinteger(floor(2.3)) also returns a 0. So how is it possible to differentiate integers from floating point numbers then?
Shubha
Shubha 2014-1-15
Oh yeah now I get it if (my_data==floor(my_data)) 'Its an integer' else 'Its a floating point value' end This works well! Thanks for the help!

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Data Import from MATLAB 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by