show all rows where value in column 13 is equal to a specific number
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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
0 comentarios
Respuesta aceptada
Image Analyst
el 4 de Mayo de 2013
Editada: Image Analyst
el 4 de Mayo de 2013
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
3 comentarios
Image Analyst
el 4 de Mayo de 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
Más respuestas (0)
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!