How to truncate the values in a column?

조회 수: 2 (최근 30일)
jrb13
jrb13 2016년 6월 6일
답변: Azzi Abdelmalek 2016년 6월 6일
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?

답변 (1개)

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

카테고리

Help CenterFile Exchange에서 Text Files에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by