Delete duplicate values from string array
조회 수: 40 (최근 30일)
I have a string array with different elements. They are random from sample to sample. In some rows I have duplicates from some elements. Which should be remove. But sadly I don't find a correct way.
SP_RL = ["Na","Mg","Mg","Si"; "K","Ca","Rb"; "Sr","Sr","Pt"]
In the end I want to have it like this:
SP_RL = ["Na","Mg","Si"; "K","Ca","Rb";"Sr","Pt"]
I tried it already with unique in a loop to delete the duplicates row after row:
At the moment I am out of ideas, because I tried everything. Does somebody has experience with the same problem?
Thank you :-)
Mitch Lautigar 2022년 5월 17일
You need to use strcmpi() which will compare strings ignoring case and have it index through each spot of the array to compare the strings.
Unique() is best for sorting numbers. Hope this helps!