Getting the nonzero mean of each cell element
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
CLARK KENDRICK GO
am 5 Apr. 2018
Beantwortet: James Tursa
am 5 Apr. 2018
Hi,
I have a cell dot_value (100x100 in size), and I wanted to find the mean of each cell (but only considering the nonzero elements). Here is my attempt:
for r1 = 1:l
for r2 = 1:w
mean_value(r1,r2) = mean(nonzeros(dot_value{r1,r2}));
end
end
I don't know why it returns an error "Conversion to cell from double is not possible."
1 Kommentar
James Tursa
am 5 Apr. 2018
Bearbeitet: James Tursa
am 5 Apr. 2018
What is the class of the dot_value elements? I.e.,
class(dot_value{1,1})
And have you pre-allocated mean_value to something?
Akzeptierte Antwort
James Tursa
am 5 Apr. 2018
Can you do this:
mean_value = cellfun(@(x)mean(nonzeros(x)),dot_value);
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Multidimensional 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!