how to remove decimals

719 views (last 30 days)
Fire on 27 Jul 2011
Commented: yogan Sganzerla on 6 Jun 2021
Hello all,
I have data with secons just for example
1.05, 2.10, 4.08, 5.09 ... etc.
I really dont want the decimal points in seconds. I just want say for above example like 1, 2, 4, 5 etc... I want to remove the decimal points completely. Can anyone suggest what code I have to use..
Thanks in advance
  1 Comment
Shreesha Subrahmanya
Shreesha Subrahmanya on 13 Apr 2021
x =[1.05, 2.10, 4.08, 5.09 ];
y =floor(x)

Sign in to comment.

Answers (5)

Oleg Komarov
Oleg Komarov on 27 Jul 2011
  1 Comment
Go Detroit Lions
Go Detroit Lions on 27 Nov 2018
Dude, I have to testify, everything you answer is on point the right answer!! Thanks!!

Sign in to comment.

Daniel Shub
Daniel Shub on 27 Jul 2011
doc round
Walter Roberson
Walter Roberson on 2 Feb 2020
Watch out: the uint*() and int*() calls round() values.

Sign in to comment.

Adi Mico
Adi Mico on 27 Jul 2011
a= [2.02 3.14 0.13];
Hope this can help you.

Daniel Shub
Daniel Shub on 27 Jul 2011
  1 Comment
Jan on 27 Jul 2011
int64(10.6) => 11. The OP did not specify if rounding or truncation is wanted.

Sign in to comment.

yogan Sganzerla
yogan Sganzerla on 4 Jun 2021
I have a similar question...
my vector in matlab is V = [1;2;3;4] and I would like to create a table with this vector in SQL.
However, what is appearing in SQL is V = [1.000000000;2.000000000;3.000000000;4.000000000;5.000000000].
I wanna the vector to be without the decimal part IN SQL.
yogan Sganzerla
yogan Sganzerla on 6 Jun 2021
Thank you for your replay Walter, however this is not what I am looking for....
I already know how to create a table im Malab and how to import in SQL. My problem is regarding the variable type in SQL. Even using uint16(V) the table in SQL has been saved asV = [1.000000;2.0000000;...5.0000000] as you can see in the photo below
theDataBaseName = '****';
theDataBaseUser = '****';
theDataBasePassword = '****';
theDataBaseDriver = 'org.mariadb.jdbc.Driver';
theDataBaseIP = '****';
tablename = 'Test';
theConnection = database(theDataBaseName, theDataBaseUser, theDataBasePassword, theDataBaseDriver, strcat('jdbc:mysql://',theDataBaseIP,'/'));
id =1:5;
id = id';
sending = table(uint16(id),'id')
The photo below shows the variable Sending and id in MATLAB
and here how it was saved in SQL.
As you can see, appears the decimal part as it was saved in SQL as decimal(38,16) instead of bigint(20) for example.

Sign in to comment.


Community Treasure Hunt

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

Start Hunting!