Commit bd5398c5 authored by Derek Cline's avatar Derek Cline

PCA write2file, created by Amir Biglari, for creating a PCA input file used with the ODT code

parent c9e8c346
function write2file( pca, filename )
%Writes the eigenvector matrix, Centering and scaling vectors to .txt
%
% Example:
% pca = PCA( x );
% pca.wite2file('pcaData.txt');
%
% INPUTS:
% pca - the PCA object
% filename - destination data file name in text format
%
% NOTE: This function writes only the eigenvector matrix, centering and
% scaling factors and not all of the pca properties
%
% See also
% AUTHOR: Amir Biglari
% DATE: August, 2013
fid=fopen(filename,'w');
fprintf(fid, '%s\n','Eigenvectors:');
fclose(fid);
dlmwrite(filename, pca.Q, 'delimiter', ',', 'precision', '%6.12f','-append');
fid=fopen(filename,'a');
fprintf(fid, '\n%s\n','Centering Factors:');
dlmwrite(filename, pca.XCenter, 'delimiter', ',', 'precision', '%6.12f','-append');fclose(fid);
fid=fopen(filename,'a');
fprintf(fid, '\n%s\n','Scaling Factors:');
fclose(fid);
dlmwrite(filename, pca.XScale, 'delimiter', ',', 'precision', '%6.12f','-append');
end
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment