How to save same input values in output

1 vue (au cours des 30 derniers jours)
Stephen john
Stephen john le 28 Juin 2022
Commenté : dpb le 29 Juin 2022
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 commentaires
Stephen john
Stephen john le 29 Juin 2022
@dpb I was offline, i accept the previous answer. But now we have four column in which we are processing second column, and produce the output, but i want the remaining column as same as in the input
dpb
dpb le 29 Juin 2022
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.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Produits


Version

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by