How to merge two matrix?
1 次查看(过去 30 天)
显示 更早的评论
Repeated values in a matrix are assigned to a group and now the elements in group has to be matched with another matrix having probability values of element in group.
For example
a=[6 6 5 6 5 6 6]
group 1 =5
3 5
group 2 = 6
1 2 4 6 7
b = [0.74 0.66 0.58 0.47 0.62 0.75 0.76]
Expecting output:
group 1 = 5
0.58 0.62
group 2 = 6
0.74 0.66 0.47 0.75 0.76
I need to apply the above mentioned problem to a larger number of group and n*m matrix. Kindly suggest me the procedure to apply for larger matrix.
Thank you in advance
0 个评论
采纳的回答
KSSV
2022-4-17
a=[6 6 5 6 5 6 6] ;
b = [0.74 0.66 0.58 0.47 0.62 0.75 0.76] ;
[c,ia,ib] = unique(a) ;
N = length(c) ;
G = cell(N,1) ;
iwant = cell(N,1) ;
for i = 1:N
G{i} = a(ib==i)
iwant{i} = b(ib==i)
end
celldisp(G)
celldisp(iwant)
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!