How to delete repeating column or duplicate column in MATLAB? of type Double
41 次查看(过去 30 天)
显示 更早的评论
Hi,
How to delete the repeating or duplicate columns in matrix, is there any function in MATLAB?, for example in the input array row 2 are basically the occurance or row 1 values, so i am basically counting how many times that partiuclar value in row 1 has appeared in row 1.
Thanks in Advance
input array:
2 2 5 1 1 3 4 3 4
2 2 1 2 2 2 2 2 2
output array:
2 5 1 3 4
2 1 2 2 2
or more precise
1 2 3 4 5
2 2 2 2 1
2 个评论
the cyclist
2019-5-17
Is the "more precise" one like that because it is sorted by the top row?
Is there any special way to handle repeated values in the top row?
采纳的回答
Matt J
2019-5-17
编辑:Matt J
2019-5-17
output_array=unique(input_array.','rows').'
5 个评论
omran alshalabi
2022-8-28
编辑:dpb
2022-8-28
how to code to delet repeating value in a row like this:
from
a = [1 2 2 4 4 2 2 1 1 4 4 ]
become
b = [1 2 4 2 1 4]
dpb
2022-8-28
This really should be a new Q? because to Answer here isn't responsive to the original -- but...
a = [1 2 2 4 4 2 2 1 1 4 4 ] ;
ix=find(diff(a));
a([1 ix+1])
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!