# Data normalization with threshold

3 views (last 30 days)
MattC on 5 Mar 2023
Commented: Star Strider on 5 Mar 2023
Hi, I am interested in normalizing my data between 0 and 1. However, I do have a threshold value/limit value that I would like to use while normalizing. Example: data: [10,30,50,75], threshold value: [70]. Good data is when it does not exceed 70. I am not sure how to incorporate this threshold while normalizing data. Please help

Star Strider on 5 Mar 2023
I am not certain what you want to do.
Perhaps one of these —
data = [10,30,50,75];
threshold_value = [70];
Result = normalize(data(data<=threshold_value), 'range',[0 1]) % Scale Only The Data To Be Considered
Result = 1×3
0 0.5000 1.0000
B = [70 1; 0 1] \ [1; 0]; % Scaling Parameters
Result = [data(data<=threshold_value).' ones(size(data(data<=threshold_value).'))] * B % Scale [0 70] —> [0 1]
Result = 3×1
0.1429 0.4286 0.7143
The first scales only the data that are less than 70 to [0 1]. The second scales [0 70] to [0 1], regardless of the data, although both limit the data to [0 70].
.
Star Strider on 5 Mar 2023
As always, my pleasure!
Accepting and voting for it is enough. Reputation points are how recognition is provided.
This will also be for other people with similar problems. For my part, I wrote the ‘Scaled’ anonymous function that I expanded to an anonymous function that can do a bivariate linear regression in a single line.
I also edited the code in my previous Comment so that the ‘ScaledResult’ table now has row names for ‘A’-‘C’, with the variable names being the days. I originally set it up for the earlier data, and now with different single data it needs to have a different format. The code in that Comment is otherwise unchanged.
.

### Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

R2020a

### Community Treasure Hunt

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

Start Hunting!