Borrar filtros
Borrar filtros

How do I access data within a cell?

2 visualizaciones (últimos 30 días)
Franchesca
Franchesca el 21 de Abr. de 2014
Editada: Walter Roberson el 21 de Abr. de 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?

Respuesta aceptada

Walter Roberson
Walter Roberson el 21 de Abr. de 2014
Editada: Walter Roberson el 21 de Abr. de 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);

Más respuestas (0)

Categorías

Más información sobre Data Type Conversion en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by