简体   繁体   English

根据另一个矩阵的相应唯一值将矩阵中的值相加

[英]adding the values in a matrix based on the corresponding unique values of another matrix

e=[40 19 18 20 30 34 65 97 155 160];

If there is a minimum difference between two consecutive values (for eg (19,18), (30, 34) and (155,160)) then merge these values.. 如果两个连续值(例如(19,18),(30、34)和(155,160))之间存在最小差,则合并这些值。

Similar values also...Whatever condition can be used to solve this..Kindly help to solve this.. 相似的值...无论使用什么条件都可以解决此问题。

Iteratively, 反复地,

e = [ 40 19 18 20 30 34 65 97 155 160];
current = e + 1; % init
prev = e;
while ~isequal( current, prev )
    prev = current;
    d = [ diff( prev ) < 5 true]; % always keep the last one
    current = prev( d );
end

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM