selection of value in particular column

1 view (last 30 days)
FIR
FIR on 9 Nov 2011
79.0000 88.0000 1.0000 0 94.9457
80.0000 87.0000 0 0 94.9107
81.0000 99.0000 1.0000 0 94.9457
82.0000 100.0000 0 0 94.9107
83.0000 88.0000 1.0000 0 94.4731
84.0000 98.0000 1.0000 0 94.9457
85.0000 88.0000 1.0000 0 94.7606
86.0000 88.0000 0 0 94.9107
95.0000 97.0000 1.0000 0 92.0663
96.0000 98.0000 1.0000 0 93.7677
97.0000 100.0000 0 0 94.9107
98.0000 100.0000 0 0 92.9658
99.0000 100.0000 1.0000 0 90.4313
i want to round off fifth column for example 90.43 as 90or 91 and i want to select values such that i may have more (90s,912s,94s,95s) ,i want t5he result such that those values (90s,912s,94s,95s)must not be more that 2 for ex(only 2 90s,91s)
can u help please

Answers (1)

Daniel Shub
Daniel Shub on 9 Nov 2011
The first part is easy
x = [
79.0000 88.0000 1.0000 0 94.9457
80.0000 87.0000 0 0 94.9107
81.0000 99.0000 1.0000 0 94.9457
82.0000 100.0000 0 0 94.9107
83.0000 88.0000 1.0000 0 94.4731
84.0000 98.0000 1.0000 0 94.9457
85.0000 88.0000 1.0000 0 94.7606
86.0000 88.0000 0 0 94.9107
95.0000 97.0000 1.0000 0 92.0663
96.0000 98.0000 1.0000 0 93.7677
97.0000 100.0000 0 0 94.9107
98.0000 100.0000 0 0 92.9658
99.0000 100.0000 1.0000 0 90.4313
];
x(:, 5) = round(x(:, 5))
I have no idea what you want for the second part. What do you want to do with all the extra 95's?
Base on your comment you can discard all but the first two occurrences of each rounded number with:
y = cell2mat(arrayfun(@(c)x(find(x(:, 5) == c, 2, 'first'), :), unique(x(:, 5)), 'UniformOutput', false));
  2 Comments
FIR
FIR on 9 Nov 2011
i want to ignore all those i needjust 2 values in each
Daniel Shub
Daniel Shub on 9 Nov 2011
See edit which ignores triplicates and beyond.

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!