Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
28 lines (22 sloc) 543 Bytes
function scalmat=scale(inmat,ranscale)
% scalmat=SCALE(inmat,ranscale)
%
% Rescales a REAL-VALUED matrix or vector to a new range
%
% INPUT:
%
% inmat Input data
% ranscale Scaling (default: [-1 1])
%
% EXAMPLE:
%
% plot(scale(scale(sin(0:0.01:3*pi),[1898 9100]),[-1 1]),'r-')
%
% Last modified by fjsimons-at-alum.mit.edu, 12/31/2018
defval('ranscale',[-1 1])
if diff(ranscale)<=0
ranscale=fliplr(ranscale);
end
reensj=max(inmat(:))-min(inmat(:));
minim=min(inmat(:));
scalmat=ranscale(1)+(inmat-minim)*range(ranscale)/reensj;
You can’t perform that action at this time.