Shorten the values from a column in another column.
Show older comments
Hello,
I have a column with 4 million values. These are categorized in 800 unique values, for example 01.010, 01.020, 05.010, 05.020 etc. I want to make a new column that shortens the unique values. So instead of it containing 01.010 and 01.020 values, I want the new column to say 01 when the values are between 01.000 and 01.999.
And the same for 02.000 .... to 02.999. So this should only assign it the value 02 instead.
I can´t figure out the way to do this and was hoping someone could help me with the coding.
Thank you!
2 Comments
the cyclist
on 25 May 2021
Are your inputs numerical values, or text? (I'm asking because MATLAB would not ordinarily display a number as 01.010.)
Can you give a small example of an input and expected output? And perhaps you could upload your full dataset in a MAT file, using the paperclip symbol in from the INSERT section of the toolbar.
Amina Ag
on 25 May 2021
Accepted Answer
More Answers (1)
the cyclist
on 25 May 2021
If these are numeric values, I think maybe you can do
output_values = unique(floor(input_values));
But see my comment above, for clarifications.
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!