How do I access data within a cell?

2 visualizzazioni (ultimi 30 giorni)
I have a variable which contains all the data within each cell, so you have to double click to open each matrix of data.
I want to count the number of zeros in the fifth column of the matrix. This is the code I have so far:
numberOfZeros = numel(mydata{7,1}) - nnz(mydata{7,1},{,:5});
It works when I didn't have the {,:5} but counted the number of zeroes in the whole matrix how do I define just column 5?

Risposta accettata

Walter Roberson
Walter Roberson il 21 Apr 2014
Modificato: Walter Roberson il 21 Apr 2014
You have an extra comma, and one set of brackets of the wrong type, and wrong notation for column 5.
size(mydata{7,1},1)) - nnz(mydata{7,1}(:,5))
size(Array,1) asks for the number of rows in the array, and number of rows is going to be the same as the number of items that are in column 5.
But I would suggest
T = mydata{7,1)(:,5);
numberOfZeros = length(T) - nnz(T);

Più risposte (0)

Categorie

Scopri di più su Data Type Conversion in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by