How do I access data within a cell?

1 次查看(过去 30 天)
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?

采纳的回答

Walter Roberson
Walter Roberson 2014-4-21
编辑:Walter Roberson 2014-4-21
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);

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Data Type Conversion 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by