selection of value in particular column

1 次查看(过去 30 天)
FIR
FIR 2011-11-9
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

回答(1 个)

Daniel Shub
Daniel Shub 2011-11-9
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 个评论
FIR
FIR 2011-11-9
i want to ignore all those i needjust 2 values in each
Daniel Shub
Daniel Shub 2011-11-9
See edit which ignores triplicates and beyond.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Import, Export, and Conversion 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by