필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

How can i see the element of the a cell element of 8*8*8?

조회 수: 3 (최근 30일)
ting
ting 2013년 11월 23일
마감: MATLAB Answer Bot 2021년 8월 20일
Given A is 35*35*35 cell, each cell contains a matrix of 8*8*8 [double]. For each matrix, elements are either 1 or 0. (It means 512 elements in each matrix)
  • A is [35* 35*35 cell]
  • A(1) is [8*8*8 double] If i want to see a designated cell says A(159) and count the number of one for each matrix How can i see this?
  1. If i want to see a designated cell says A(159) and count the number of one for each matrix How can i see this?
  • I tried "A(159)" gives me [8x8x8 double] but i want to see all 512 elements.
  • Some background information: A big 3d matrix is cut and form cells. I want to perform 3d dct for each cell. but before that, i want to count the ones in each cells first as there are many equal cells, for example a cell with all 512 zeros. If I can find all zero cell, I can reduce the complexity of 3d dct.
Please also provide some codes, thank you

답변 (2개)

Azzi Abdelmalek
Azzi Abdelmalek 2013년 11월 23일
a=A{159};
out=sum(a(:))

Image Analyst
Image Analyst 2013년 11월 23일
Simply have A{159} all by itself on a command line to see the values
A{159}
Then to count the number of elements of each value you can use hist() or histc(). If you have specific values in mind, use sum
numberOfOnes = sum(A{159} == 1);
numberOfZeros = sum(A{159} == 0);
% Count number of non-zeros
if nnz(A{159}) == 0
% Array is all zeros, so now can simplify.
% Your code to simplify
end

이 질문은 마감되었습니다.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by