Remove repeated values in a CSV string
显示 更早的评论
I have a string with comma separated values, and would like to delete the repeated values so that there are no repeats in my string.
mystring = '1,1,1,25,33,33,5,5,3,2,1,1'
Iwant = '1,25,33,5,3,2'
The order of the numbers in "Iwant" is not important. It could be '1,25,33,5,3,2' or "1,33,5,25,3,2" or "2,3,5,33,1,25" (whatever works).
I have many other strings I would like to edit, so it would be great if the code could apply to a string with any manner of numbers in it.
2 个评论
Walter Roberson
2019-4-19
Are the values certain to be numeric? Are they certain to be integer? If they might be floating point, then would 25.70 be considered different than 25.7 ?
Matthew Tyler Jeffries
2019-4-19
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Characters and Strings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!