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

📄 svpca.m

📁 收集的GA的一些源程序
💻 M
字号:
function [out]=svpca(fname,inc,meanx,stdx,pcs)
%
%
% Saves a neural network type model to file
%
% fname	= file name
% inc	= matrix of included variables
% meanx	= mean x-values
% stdx	= Standard deviation of x-values
% meany	= mean y-value
% stdy	= standard deviation of y-value
% pcs	= principal component scores
%

%
% Open the file. If none is supplied, then put
% up a dialog box
%
if fname == []
	[df_name df_path]=uiputfile('*.pca','Please select a model file');
	if df_name ~= 0
		%
		% Change to the directory
		%
		[D L]=size(df_path);
		if L == 3
			if df_path ~= 'C:\'
				df_path=df_path(:,1:L-1);
			end
		else
			df_path=df_path(:,1:L-1);
		end
		eval(['cd ' num2str(df_path)]);
		fname=df_name;
	else
		fname=[];
	end
end

if fname ~= []

	%
	% Calculate various parameters
	%
	% *** Output MUST be first column!
	% *** MUST be only one output
	%
	[D L]=size(inc);
	num_inc=sum(inc);
	tot_var=L;

	f=fopen(fname,'w');
	%
	% Header
	%

	fprintf(f,'[Principal components information]');
	fprintf(f,'\n');
	fprintf(f,'\n');

	%
	% Total variables
	%
	fprintf(f,'[Number of variables]');
	fprintf(f,'\n');
	fprintf(f,num2str(tot_var));
	fprintf(f,'\n');
	fprintf(f,'\n');
	
	%
	% Number of included variables
	%
	fprintf(f,'[Number used]');
	fprintf(f,'\n');
	fprintf(f,num2str(num_inc));
	fprintf(f,'\n');
	fprintf(f,'\n');

	%
	% Included variables
	%
	fprintf(f,'[Included variables]');
	fprintf(f,'\n');
	for i=1:tot_var
		fprintf(f,num2str(inc(i)));
		fprintf(f,'\n');
	end
	fprintf(f,'\n');

	%
	% Mean x-values for scaling
	%
	count=1;
	fprintf(f,'[Mean process values]');
	fprintf(f,'\n');
	for i=1:tot_var
		if inc(i)==1
			fprintf(f,num2str(meanx(count)));
			fprintf(f,'\n');
			count=count+1;
		end
	end
	fprintf(f,'\n');

	%
	% Standard deviation of x-values for scaling
	%
	count=1;
	fprintf(f,'[Standard deviations]');
	fprintf(f,'\n');
	for i=1:tot_var
		if inc(i)==1
			fprintf(f,num2str(stdx(count)));
			fprintf(f,'\n');
			count=count+1;
		end
	end
	fprintf(f,'\n');
	
	%
	% Principal component scores
	%
	fprintf(f,'[PC scores]');
	fprintf(f,'\n');
	for i=1:num_inc
		for j=1:num_inc
			fprintf(f,num2str(pcs(j,i)));
			fprintf(f,'\n');
		end
	end
	fprintf(f,'\n');

	%
	% Close the file
	%
	fprintf(f,'[END]');
	fclose(f);
	out=1;
else
	out=0;
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -