Trying to calculate variance in cells nested within a 1x9 cell
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Currently I have a variable that is a 1x9 cell (lets call it X). Within X, there are a variety of different sized nested cells, such as 1700x1, 1500x1, etc).
I want to create a new variable that contains the variance for each of those 9 cells in its own 1x9 array.
I've been trying to work out the issue myself, and so far I've run into an issue calculating the variance for just 1 column in X.
A = cellfun(@var,X{1,1}) --- However, this gives me a very long list of values the same height as the column I am working with. For instance, it will output 1700 values for variance, and I'm not sure where exactly it is getting this numbers from.
Hopefully this makes sense, does anyone have any suggestions?
0 Kommentare
Antworten (1)
Robert U
am 6 Jun. 2018
Bearbeitet: Robert U
am 7 Jun. 2018
Hello Jonathan Marchetto:
I generated data that should fit your description:
X = {};
for ik = 1:9
X{ik} = num2cell(rand(1700-200*(ik-1),1));
end
From what you describe this should work to calculate variance for each sub-cell values:
A = cellfun(@(cIn) var(cell2mat(cIn)),X);
Kind regards,
Robert
0 Kommentare
Siehe auch
Kategorien
Mehr zu Matrices and Arrays 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!