How to save same input values in output
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
dpb
am 29 Jun. 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.
Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!