How to put multiple elements in a cell?
10 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I am loading in a mat file that contains a 6 X 191 cell (contains pixels).
*I am not able to upload a zip file of the mat file because of the size so I took a screenshot.
I want to calculate the mean, medican, std, skewness, and kurtosis for each column.
Then I want to take each of the column's statistic and put it in a array with 5x1 elements in each cell. (1 x 191 cell array with 5 elements in each cell)
Is that possible? In the future, I want to make a for loop out of this, so I can go through multiple mat files.
I have this code so far.
I tried using the vertcat and I ended up getting a 5 X 191 double (i don't know if it turned to a matrix).
% lead feats.mat
load('Feats.mat');
% calculate various statistics per column
feat_mean = arrayfun(@(k) mean([featints{1,k} ; featints{2,k}]), 1:size(featints,2));
feat_med = arrayfun(@(k) median([featints{1,k} ; featints{2,k}]), 1:size(featints,2));
feat_std = arrayfun(@(k) std([featints{1,k} ; featints{2,k}]), 1:size(featints,2));
feat_skw = arrayfun(@(k) skewness([featints{1,k} ; featints{2,k}]), 1:size(featints,2));
feat_kurt = arrayfun(@(k) kurtosis([featints{1,k} ; featints{2,k}]), 1:size(featints,2));
% combine all the stats into different rows
combine_feat_stat = vertcat(feat_mean, feat_med, feat_std, feat_skw, feat_kurt);
% 5X1 elements in each cell
0 comentarios
Respuestas (1)
KSSV
el 10 de Abr. de 2020
Let A be your 6*191 cell array.
[m,n] = size(A) ;
M = zeros(1,n) ; % initialize mean
for i = 1:n
C = cell2mat(A(:,i)) ; % convers the first column of cells into array
M(i) = mean(C) ;
end
1 comentario
Nandini Chatterjee
el 10 de Abr. de 2020
Editada: Nandini Chatterjee
el 10 de Abr. de 2020
Ver también
Categorías
Más información sobre Matrices and Arrays en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!