finding duplicate number and adjacent row value
显示 更早的评论
Suppose I have a matrix of values
v = [1 4; 1 5; 2 4; 2 4; 2 5; 2 5; 3 4; 3 7]
in column one the numbers are consecutive but with repetition, how can I find only the first numbers and corresponidng number in the other column, put them in a new matrix (v')? The new matrix should be like this from my example:
v'= [1 4; 2 4; 3 4]
I hope I am clear enough
Cheers
Sobhan
1 个评论
Azzi Abdelmalek
2012-9-16
编辑:Azzi Abdelmalek
2012-9-16
what if v= [1 4; 1 5; 2 4; 2 4; 2 5; 2 5; 3 4; 3 7;1 5;1 6]?
采纳的回答
更多回答(1 个)
Wayne King
2012-9-16
编辑:Wayne King
2012-9-16
[~,iv] = unique(v(:,1),'stable');
vnew = v(iv,:);
类别
在 帮助中心 和 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!