Histogram struggles (excluding low values and multiplying all the data)

Hi,
I’m trying to make histogram out of some data
lc = cellfun(@(c) c(end,6),particles);
hist(lc, 20)
How do I exclude values lower than 2 from the histogram? (as this back ground noise and looks messy)
ALSO - the data is current in the wrong units and I would convert it by multiplying by 7.431 (for example)
So to apply this to the data in the histogram would I do:
lc = cellfun(@(c) c(end,6),particles)
f=lc*7.431
hist(f,20)
Thanks in advance :)

 Accepted Answer

Use masking:
goodIndexes = particles >= 2;
histogram(particles(goodIndexes), 20);
particles is your data array.

3 Comments

Undefined operator '>=' for input arguments of
type 'cell'.
Well then use whatever array has your data in it:
yourData = yourData >= 2;
histogram(particles(yourData), 20);
yourData would be a numerical array, like double or int32, not a cell array. http://matlab.wikia.com/wiki/FAQ#What_is_a_cell_array.3F
Extract yourData from the cell array if you have to. Maybe that's what lc is, so maybe you can use lc. I don't know what lc is - that's why I always use descriptive variable names.
Sorry, lc is cumulative length but I didn't explain and it worked the second time I used it for some reason! Thank you for your help :)

Sign in to comment.

More Answers (0)

Categories

Find more on MATLAB in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!