Asked by Locks
on 4 May 2013

Hi,

I know that I can display all elements of the first column of a matrix that are larger than 1500 by using this command:

find(data18(:,1)>1500);

However, I would like to find all the rows where the value in column 13 is equal to one and I tried this:

find(data18(:,13)==1);

From what I can see, this is not working. What is wrong with that code?

In addition, I would like to see not only the value in those columns where the value is equal to 1, but also from all other elements of that specific row

*No products are associated with this question.*

Answer by Image Analyst
on 4 May 2013

Edited by Image Analyst
on 4 May 2013

Accepted answer

Probably because data18 is floating point, not integer. And in the second case you're checking for EQUALITY, while in the first case you were checking for "greater than." Please read and understand the FAQ on this topic: http://matlab.wikia.com/wiki/FAQ#Why_is_0.3_-_0.2_-_0.1_.28or_similar.29_not_equal_to_zero.3F

Locks
on 4 May 2013

Sorry, I made a mistak, column 9 and 13 are pretty similar, but I was looking for column 9 instead of 13 and there it works, thanks

is there a way I can see for how many elements there are just two elements with the same number in colum 9?

for example when I do this:

data18((data18(:,9)==1),:)

I get two rows, to be more precise I get row 1 and row 105 which both belong to the series 1 and which are also the only elements in series 1

I would like to know how many series (number in column 9 gives me the seriesID) are there that consist of only two elements?

Image Analyst
on 4 May 2013

Try this:

% Create an array of random integers, from 1 to 8, % in a 20 row by 9 column matrix. data18 = int32(randi(8, [20,9])) % Extract only column 9 column9 = data18(:, 9) % Get a count of how many times each number, % from 1 up to the max of column9, appears. counts = histc(column9, 1:max(column9)) % Find out which integers have exactly 2 occurrences: numbersOccurringTwice = find(counts == 2)

Sample run in the command window:

column9 = 4 4 1 1 8 5 3 3 2 2 3 3 7 4 4 2 8 6 7 6 counts = 2 3 4 4 1 2 2 2 numbersOccurringTwice = 1 6 7 8

Opportunities for recent engineering grads.

## 0 Comments