Effacer les filtres
Effacer les filtres

How do I access data within a cell?

1 vue (au cours des 30 derniers jours)
Franchesca
Franchesca le 21 Avr 2014
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?

Réponse acceptée

Walter Roberson
Walter Roberson le 21 Avr 2014
Modifié(e) : Walter Roberson le 21 Avr 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);

Plus de réponses (0)

Catégories

En savoir plus sur Data Type Conversion dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by