在Matlab中对可变范围[x,y]进行归一化 [英] Normalization in variable range [ x , y ] in Matlab
本文介绍了在Matlab中对可变范围[x,y]进行归一化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想创建基本的matlab程序,以对给定范围内的给定整数数组进行规范化.
I wanna create basic matlab program that normalizes given array of integer in the given range.
- 输入是数组[a1,a2,a3,a4,a5,a6,a7 ...]和范围[x,y]
- 输出是标准化数组.
但是在任何地方,我看到的归一化范围为[0,1]或[-1,1].找不到可变范围归一化. 如果您编写了matlab代码或变量范围公式,请多谢.
But in everywhere, i see the normalization in the range of [0,1] or [-1,1]. Can't find variable range normalization. I will be grateful if you write the matlab code or the formula for variable range.
感谢您的想法.
推荐答案
如果要归一化为[x, y]
,请先通过以下方式归一化为[0, 1]
:
If you want to normalize to [x, y]
, first normalize to [0, 1]
via:
range = max(a) - min(a);
a = (a - min(a)) / range;
然后通过以下方式缩放为[x,y]
:
Then scale to [x,y]
via:
range2 = y - x;
a = (a * range2) + x;
将它们放在一起:
function normalized = normalize_var(array, x, y)
% Normalize to [0, 1]:
m = min(array);
range = max(array) - m;
array = (array - m) / range;
% Then scale to [x,y]:
range2 = y - x;
normalized = (array*range2) + x;
这篇关于在Matlab中对可变范围[x,y]进行归一化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文