How to save same input values in output
1 次查看(过去 30 天)
显示 更早的评论
Hello everyone, I hope you are doing well.
I have the four cells and each cell has four column .
i applied the following algorithm which find the histogram of second column of each cell, and find the unique value and count and repeat the values based on count.
At the output i only get single column in the cell, but i want the the 2nd preprocessed column with all other column which present in the input of each cell. How can i do it in MATLAB
K=4
for i = 1:K
T = C1{i}(:,2);
h1(i)=histogram(T,100000,'BinLimitsMode','manual','BinLimits',[0 3e8]);
BindataF{i}=h1(i).Data;
T1=BindataF{i};
Values=unique(T1);
counts=histc(T1(:),Values);
val{i}=Values;
cnts{i} = counts;
end
for k =1:K
c = cnts{k};
v = val{k};
z=k+1;
for j=z:K
temp = val{j};
cnt_temp = cnts{j};
for m = 1: length(v)
for n = 1: length(temp)
if v(m)== temp(n)
c(m)=c(m)+cnt_temp(n);
temp(n)= nan;
cnts{j}(n) = nan;
end
end
cnts{k}(m) = c(m);
end
val{j} = temp;
end
end
fnRM=@(v,c)repmat(v,1,c);
for i=1:numel(val)
ix=isfinite(cnts{i});
C{i}=cell2mat(arrayfun(fnRM,val{i}(ix),cnts{i}(ix),'UniformOutput',false).');
Cluster{i}=C{1,i}.';
end
5 个评论
dpb
2022-6-29
Again, don't try to describe, SHOW a small example input and expetced output...it's much faster for us and more likely to result in the actual result described--I really don't follow the above precisely and don't have time to try to puzzle it out.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!