Logical indexing of cell array

Hi all,
There is a probably a very simple solution to this but my mind has gone blank. I have a matrix which I am filtering on using logical indexing of another matrix e.g.
new_matrix=old_matrix(diff_matrix>50)
This works fine however I am trying to do the same thing, this time with a cell array e.g
new_cell_Array=old_cell_Array(diff_matrix>50)
but in this instance nothing happens - the old array and new array are the same size. Any ideas of how I use indexing to filter to the same entries in my cell array as my matrix?
I hope this makes sense

3 commentaires

Star Strider
Star Strider le 3 Nov 2015
It makes sense, but since cell arrays have different structures, we need ‘old_cell_Array’ and ‘diff_matrix’ in order to provide any substantive help.
Saving them to a .mat file (use the save function) and attaching them here (use the ‘paperclip’ icon and complete both the ‘Choose file’ and ‘Save file’ steps) would be the easiest way to share them.
jnaumann
jnaumann le 4 Nov 2015
Thanks for your response - I have added the data I mentioned in my first post
Adam
Adam le 4 Nov 2015
When I run your code on those arrays I get a result array that is 5 elements shorter than the old_cell_array so it seems to work fine. The syntax is certainly fine since diff_matrix is a logical array.

Connectez-vous pour commenter.

Réponses (1)

Thorsten
Thorsten le 4 Nov 2015
Modifié(e) : Thorsten le 4 Nov 2015

0 votes

I tried it with your variables and it worked fine.
>> size(old_cell_array)
ans =
196.00 1.00
>> new_cell_array=old_cell_array(diff_matrix>50);
>> size(new_cell_array)
ans =
191.00 1.00
Maybe you confused old_cell_array and old_cell_Array, or something like that?

Catégories

Modifié(e) :

le 4 Nov 2015

Community Treasure Hunt

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

Start Hunting!

Translated by