mean from intersection matrix
1 次查看(过去 30 天)
显示 更早的评论
Hi matlab community
Suppose i have matrix:
a = [1,3,3,2,2,3,3,4,3,1,3];
b = [1,1,1,3,4,1,2,1,4,1,1];
c = [2,2,2,4,2,3,3,2,1,3,8];
now, I want to get the mean value (from matrix c) of the intersection of matrices [ab] which have the same value, like this:
a = [1,3,2,2,3,4,3];
b = [1,1,3,4,2,1,4];
c = [2.5,3.75,4,2,3,2,1]; %final result
how to do it? tks :)
0 个评论
采纳的回答
Ive J
2021-10-16
This should work:
a = [1,3,3,2,2,3,3,4,3,1,3];
b = [1,1,1,3,4,1,2,1,4,1,1];
c = [2,2,2,4,2,3,3,2,1,3,8];
x = [a; b];
[~, ia, ic] = unique(x.', 'stable', 'rows');
newC = arrayfun(@(x) mean(c(ic == x)), unique(ic)).'
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Biomedical Imaging 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!