poster
2019-12-14, 20:13
如何将向量归一化为 [-1;1]
我想使用function norm ,因为它将更快。
也让我知道我怎么能归一化后非规范化是矢量?
回答:
norm归一化向量,以使其平方和为1。
如果要归一化向量,使其所有元素都在0到1之间,则需要使用最小值和最大值,然后可以使用该值再次进行归一化。
%# generate some vector vec = randn(10,1); %# get max and min maxVec = max(vec); minVec = min(vec); %# normalize to -1...1 vecN = ((vec-minVec)./(maxVec-minVec) - 0.5 ) *2; %# to "de-normalize", apply the calculations in reverse vecD = (vecN./2+0.5) * (maxVec-minVec) + minVec
更多&回答... (https://stackoverflow.com/questions/4684622)
我想使用function norm ,因为它将更快。
也让我知道我怎么能归一化后非规范化是矢量?
回答:
norm归一化向量,以使其平方和为1。
如果要归一化向量,使其所有元素都在0到1之间,则需要使用最小值和最大值,然后可以使用该值再次进行归一化。
%# generate some vector vec = randn(10,1); %# get max and min maxVec = max(vec); minVec = min(vec); %# normalize to -1...1 vecN = ((vec-minVec)./(maxVec-minVec) - 0.5 ) *2; %# to "de-normalize", apply the calculations in reverse vecD = (vecN./2+0.5) * (maxVec-minVec) + minVec
更多&回答... (https://stackoverflow.com/questions/4684622)