⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 range.m

📁 人工神经网络:MATLAB源程序用于训练测试
💻 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 + -