?? range.m
字號:
%#
%# function [rdata,table,rnewdata] = range(data,mn,mx,newdata)
%#
%# AIM: Each element in the data set is scaled to a range determined
%# by the user.
%#
%# PRINCIPLE: The training set is scaled so that its extrema match the extrema
%# determined by the user. Optionally, a test set can be scaled to the
%# same range.
%#
%# Reference :
%# M.A.Sharaf, D.L.Illman, B.R.Kowalski, "Chemometrics"
%# Wiley & Sons, Chichester, UK (1986)
%#
%# INPUT: data (m*n) : training set (It can be a column-vector, a row-vector or
%# a matrix).
%# mn : minimum of the new range
%# mx : maximum of the new range
%# newdata (mt*n) : test set (optional)
%#
%# OUTPUT: rdata (m*n) : range-scaled training set.
%# table (1*2) : row vector containing the minimum and maximum
%# values of the training set
%# rnewdata (mt*n) : range-scaled test set (optional)
%#
%# AUTHOR: Frederic Despagne
%# Copyright(c) 1997 for ChemoAC
%# Dienst FABI, Vrije Universiteit Brussel
%# Laarbeeklaan 103, 1090 Jette
%#
%# VERSION: 1.1 (28/02/1998)
%#
%# TEST: Andrea Candolfi
%#
function [rdata,table,rnewdata] = range(data,mn,mx,newdata)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%% RANGE-SCALING OF THE TRAINING SET %%%%%%%%%%%%%%%%%%%%%%%%%
[m,n] = size(data); % Size of training matrix
rn = mx-mn; % New range
xmn = min(min(data)); % Minimum of the original data set
xmx = max(max(data)); % Maximum of the original data set
for i = 1:n
for j = 1:m
rdata(j,i) = (data(j,i)-xmn)/((xmx-xmn))*rn+mn; % Range-scaling
end;
end;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%% RANGE-SCALING OF THE TEST SET %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if nargin == 4
mt = size(newdata,1); % Number of test samples
for i = 1:n
for j = 1:mt
rnewdata(j,i) = (newdata(j,i)-xmn)/((xmx-xmn))*rn+mn; % Range-scaling
end;
end;
end
table = [xmn xmx]; % Output vector with extrema of the training set
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -