Trying to calculate variance in cells nested within a 1x9 cell
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Robert U
el 6 de Jun. de 2018
Editada: Robert U
el 7 de Jun. de 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 comentarios
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!