Effacer les filtres
Effacer les filtres

To find n number of histcounts in a loop

2 vues (au cours des 30 derniers jours)
SP
SP le 14 Juil 2022
Commenté : KSSV le 14 Juil 2022
Hi,
I am having a cell array (c) of 3000*2 cell, each containing 1*1000 matrix values. Here I need to find histcounts of each cell and concatenate horizontally. I have used following code to calculate individually, but I need to do for all 3000*2 cell in a loop and store it in a separate cell array (z) of dimension 3000*30. (since bin count is 15 for each column).
[N{1},edges{1}] = histcounts(c{1,1},15); % bin count=15 % column 1
[N{2},edges{2}] = histcounts(c{1,2},15); % column 2
z = horzcat(N{1,1}, N{1,2}); %horizontal concatenation
How can I do this? Kindly help me with this. Thanks in advance.

Réponse acceptée

KSSV
KSSV le 14 Juil 2022
Modifié(e) : KSSV le 14 Juil 2022
z = cell2mat(N) ;
Or
z = [N{:}] ;
  4 commentaires
SP
SP le 14 Juil 2022
By using this I am able to find only a single row of c{1,1} and c{1,2}. I need to find for all 3000*2 cell in a loop.
KSSV
KSSV le 14 Juil 2022
Are you looking for?
[m,n] = size(c) ;
z = cell(m,1) ;
for i = 1:m
[N{1},edges{1}] = histcounts(c{i,1},15); % bin count=15 % column 1
[N{2},edges{2}] = histcounts(c{i,2},15); % column 2
z{i} = horzcat(N{1,1}, N{1,2}); %horizontal concatenation
end

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

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

Community Treasure Hunt

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

Start Hunting!

Translated by