selection of value in particular column
1 view (last 30 days)
Show older comments
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
0 Comments
Answers (1)
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
See Also
Categories
Find more on Import, Export, and Conversion in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!