MATLAB Answers

How to deal with repeated data in a column of a table

2 views (last 30 days)
QIAO WANG
QIAO WANG on 30 Oct 2019
Commented: QIAO WANG on 13 Nov 2019
Hey,
I'm currently trying to process a table. What I want is to extract a sequence from a column of it. Before I used unique but apparently the result wasn't what I intended for.
An example of the table could be like below. I want to extract [22 24 22] for vid 59. However, unique only gave me [22 24], which is not what I want. So, I hope I've explained my question well. Appreciate your advice on this!!
TableC.PNG

Accepted Answer

Cyrus Tirband
Cyrus Tirband on 30 Oct 2019
Edited: Cyrus Tirband on 30 Oct 2019
It sounds like you're looking to remove repeating elements that are adjecent. If that is the case, you can test your array for differences between each element and remove the parts where the difference is 0.
If your array is named A, then:
A(diff(A)==0) = []
  8 Comments
QIAO WANG
QIAO WANG on 13 Nov 2019
Thank you Cyrus. Actually, before you replied to me, I also raised a question in the community and got a good one. Anyway, yours is a brilliant idea! Worked for me too.

Sign in to comment.

More Answers (0)

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!