Filter löschen
Filter löschen

Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

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

3 Ansichten (letzte 30 Tage)
ting
ting am 23 Nov. 2013
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
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

Antworten (2)

Azzi Abdelmalek
Azzi Abdelmalek am 23 Nov. 2013
a=A{159};
out=sum(a(:))

Image Analyst
Image Analyst am 23 Nov. 2013
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

Diese Frage ist geschlossen.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by