필터 지우기
필터 지우기

Getting the nonzero mean of each cell element

조회 수: 1 (최근 30일)
CLARK KENDRICK GO
CLARK KENDRICK GO 2018년 4월 5일
답변: James Tursa 2018년 4월 5일
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
James Tursa
James Tursa 2018년 4월 5일
편집: James Tursa 2018년 4월 5일
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?

댓글을 달려면 로그인하십시오.

채택된 답변

James Tursa
James Tursa 2018년 4월 5일
Can you do this:
mean_value = cellfun(@(x)mean(nonzeros(x)),dot_value);

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Types에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by