arrays - Choosing cells in a struct with specific conditions -


data looks more this:

t = struct('direction',            {[1,1,1,1],[1,1,2,1],[2,2,2,2,2],             [2,2,2,2,1,2], [2,2,2,2,2],[3,1,4,5]},            'tr‌ial',             {'correct','incorrect','incorrect','correct','correct','incorrect'});  

this example , have other fields well

t = t(arrayfun(@(x) all(x.direction == 2), t));  

i have above code works fine gives me [2,2,2,2,2] , not give me cell [2,2,2,2,1,2] because has 1.

i tried using <= 2 includes [1,1,1,1],[1,1,2,1] well. there way this? want 2 things:

  1. cells contain all 2 or 1 , allow maximum 1 element different can both [2,2,2,2,2],[2,2,2,2,1,2] unlike code gives [2,2,2,2,2]
  2. cells contain random numbers

i appreciate help.

thank

you can change condition

sum( x.direction == 2 ) + 1 >= numel( x.direction ) 

this should return true if 1 of elements 1


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -