将矩阵缩放到新范围

时间:2013-01-16 17:01:36

标签: matlab matrix

  

可能重复:
  MATLAB: how to normalize/denormalize a vector to range [-1;1]
  matlab rescale matrix data to -1 to 1

考虑一个100x200矩阵A,是否有一个builtin函数(或一组builtin函数)将A的范围设置为任意比例?< / p>

1 个答案:

答案 0 :(得分:3)

这有资格吗?

R = [.5 .9];
dR = diff( R );

A =  A - min( A(:)); % set range of A between [0, inf)
A =  A ./ max( A(:)) ; % set range of A between [0, 1]
A =  A .* dR ; % set range of A between [0, dRange]
A =  A + R(1); % shift range of A to R