how to set a range of data instead of percentile?

2 views (last 30 days)
I want to set a range of data instead of percentile
I used percentile to do this before.
but big problem occured when the number (which is correspond to high percentile or low percentile) is outlier or error.
for example, when the data is [1 2 3 4 5 6 7 8 9 10] and set a range of data with 5 percentile and 95 percentile, there is no problem.
the range of data looks fine
but. when tha data is [1 2 3 4 5 6 7 8 9 50000], the range of data is from 1 to 50000.
I know there is no problem with percentile. I just want to know if there is a better way to set a range of data.
In this case, I want the range of data to be from 1 to the number which is closet to [1 2 3 4 5 6 7 8 9].
I've been thinking that giving a weight to [1 2 3 4 5 6 7 8 9]. but i don't know how to that.
my actual data is much bigger than this. so i can't just simply delete the data.

Accepted Answer

Torsten
Torsten on 26 Jun 2022

More Answers (1)

Image Analyst
Image Analyst on 26 Jun 2022
Explain what you mean by setting a range of data. The range of the data is what it is. If you want to scale the data to a different, new range you can use rescale, for example to scale to the range 300 to 4800
data = rescale(data, 300, 4800);
This will do it without clipping. If you want to clip and also rescale, you can do that.
You say "I want the range of data to be from 1 to the number which is closet to [1 2 3 4 5 6 7 8 9]" That's clear as mud. Range is from 1 to what? What should be closest to one of those 9 numbers? If 1 is the low end of the range, and apparently you want one of those 9 numbers to be the upper end of the range, but which one??? The one that is "closest". Closest to what?

Community Treasure Hunt

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

Start Hunting!

Translated by