How to truncate the values in a column?

2 views (last 30 days)
jrb13
jrb13 on 6 Jun 2016
Answered: Azzi Abdelmalek on 6 Jun 2016
I have data in a cell array, and one column has a list of unique IDs. The IDs start at 1.00E+09 and ascend by 1. When I write the data to a .csv file using dlmwrite, the IDs in that column are all 1.00E+09 and are no longer unique. I want to know if there is a way to truncate the ID numbers from the left side (e.g. 1000000000, 1000000001, 1000000002 to 00000, 00001, 00002). I never have more than 10000 data points, but the auto-output of our analysis software starts at 1000000000.
How would you do this? Write a function that subtracts 1.00E+09 from every ID?

Answers (1)

Azzi Abdelmalek
Azzi Abdelmalek on 6 Jun 2016
a=1000000001;
b=sprintf('%05d',a-10^9)

Community Treasure Hunt

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

Start Hunting!