-1

I have a matrix called event of type double 6000 x 5350. The matrix is full of numbers which are codes. What I would like is to get a logical vector of where any element in a column is greater than or equal to 100.

The line of code below returns a logical vector which is what I am looking for however I am not interested if the element isnan.

 act_deal = isnan(event(:, i));

I would like to substitute the isnan condition for something like the below line. However this will only return the row number where this condition is true.

act_deal = find(event(:, i) >= 100); 

Below is an simple example of what I am looking for.

 one column of event matrix
 50
 99
 100
 105
 23
 100
 62

the result I would like back is

 0
 0
 1
 1
 0
 1
 0
Machavity
  • 30,841
  • 27
  • 92
  • 100
mHelpMe
  • 6,336
  • 24
  • 75
  • 150
  • 3
    what happens if you omit the `find`? try just `event(:,i)>=100` – Shai Jul 23 '14 at 10:13
  • 2
    BTW, it is best [not to use `i` as a variable name in Matlab](http://stackoverflow.com/questions/14790740/using-i-and-j-as-variables-in-matlab). – Shai Jul 23 '14 at 10:15

1 Answers1

2

Logical indexing!

act_deal = event(i,:)>=100

will give you the result you ask for here.

act_deal = event(i,event(i,:)>=100)

will give you the actual values.

Tom
  • 142
  • 1
  • 9