Filter löschen
Filter löschen

How do I access data within a cell?

2 Ansichten (letzte 30 Tage)
Franchesca
Franchesca am 21 Apr. 2014
Bearbeitet: Walter Roberson am 21 Apr. 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?

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 21 Apr. 2014
Bearbeitet: Walter Roberson am 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);

Weitere Antworten (0)

Kategorien

Mehr zu Data Type Conversion finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by