rescaledata

Rescale data, including least-squares baseline fits.

Syntax
y_ = rescaledata(y,yref,mode)
y_ = rescaledata(y,mode)
[y_,scalefactors] = rescaledata(...)
Description

This function rescales the data in the vector y and returns it in y_. The type of rescaling depends on the setting mode and on the presence or absence of a reference data vector yref.

If a second data set is given in yref, the data in y are rescaled and shifted in a way depending on the value of mode:

In all cases, positive rescaling is enforced, i.e. the rescaled data is not inverted.

Without a reference data vector, the rescale options (given in mode) are more limited:

scalefactors is an optional ouput that includes the scale, shift and polynomial coefficients (against an abscissa running from 0 to 1).

Examples

Generate a Gaussian signal and a noisy version of it with a linear baseline drift

n = 200;
x = linspace(-1,1,n);
yn = gaussian(x,0,0.5);
y1 = yn + 0.5*randn(1,n) + 2*x;
plot(x,yn,x,y1)

The noisy signal can be rescaled in various ways to fit the noise-free one:

y2 = rescaledata(yn,y1,'minmax');
y3 = rescaledata(yn,y1,'lsq0');
y4 = rescaledata(yn,y1,'lsq1');
plot(x,y1,x,y2,x,y3,x,y4);
legend('input','minmax','lsq0','lsq1');

In this case, 'lsq1' is needed to remove the linear background.

See also

deriv, rcfilt, datasmooth