How to find both cell array and non-cell array values in Table?

1 visualizzazione (ultimi 30 giorni)
I have a table that looks like this:
test = table([1;2;3;4], {'New'; 'Old'; 'New'; {'New'; 'Test'}});
where the second column is a combination of char arrays and cell arrays. How can I count the number of occurances of a word? For example, if I wanted to count how many row are considered 'New', I would expect count 3. But if I do
nnz(strcmp(test.Var2, 'New'))
I get a result 2. Is there a one line of code that could do this, or do I need to use a loop? I find that looping through each row of a table much slower.

Risposte (0)

Tag

Prodotti


Release

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by