How to normalize output data

조회 수: 2 (최근 30일)
Giovanni Ponce
Giovanni Ponce 2022년 7월 13일
답변: Neha 2023년 8월 31일
I want to normalize output and input data of my simulink model algorithm. But I don't want to just rescale the limits of the Y-axis plot from -2 to 2. I tried this formulas, but they only rescale the Y-axis without the actual data
Normailized_data_Pset = (sim_data.Pset-min(sim_data.Pset))/(max(sim_data.Pset)-min(sim_data.Pset));
or another formula.......
T = [sim_data.Pset];
H = normalize (T);
I want to normilize the actual data from -2 to 2 to plot the data inbetween those values.
How would I do that?

답변 (1개)

Neha
Neha 2023년 8월 31일
Hi Giovanni,
I understand that you want to normalize your data from the range of -2 to 2 without rescaling the limits of the Y-axis. You can refer to the following code snippet:
% Normalize input data
normalized_input = ((input_data - min(input_data)) * (4 / (max(input_data) - min(input_data)))) - 2;
% Normalize output data
normalized_output = ((output_data - min(output_data)) * (4 / (max(output_data) - min(output_data)))) - 2;
The formula first normalizes the data between 0 and 1 using the "min" and "max" functions. It then scales the normalized data between -2 and 2 by multiplying it with 4 and subtracting 2.
Hope this helps!

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by