How to normalize / denormalize a vector to range [-1;1]

后端 未结 4 1591
醉话见心
醉话见心 2020-11-29 05:39

How can I normalize a vector to the range [-1;1]

I would like to use function norm, because it will be faster.

Also let me

4条回答
  •  一向
    一向 (楼主)
    2020-11-29 05:54

    A simple solution is using ready MATLAB function :

    mapminmax
    

    Process matrices by mapping row minimum and maximum values to [-1 1]

    Example :

    x1 = [1 2 4; 1 1 1; 3 2 2; 0 0 0]
    [y1,PS] = mapminmax(x1)
    

    Denormalize that vector after normalization

    x1_again = mapminmax('reverse',y1,PS)
    

提交回复
热议问题