Extract two closest rows of a matrix
1 次查看(过去 30 天)
显示 更早的评论
Hello,
How can I extract two closest rows of a matrix and set one of them to zero?
thank you.
3 个评论
Image Analyst
2016-3-20
Well, here is the "set to zero" part
yourMatrix(closestRow, :) = 0;
to determine what scalar value you need for closestRow, you need to answer dpb's question.
采纳的回答
dpb
2016-3-21
d=pdist(M(:,2)); % find the pairwise differences
ix=find(min(d(1:end-1)); % shortest distance excluding wraparound of 3-1
M(ix,:)=[]; % remove that row
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!