Files
it-labs/ТЕМА2/Progl.m

39 строки
1.0 KiB
Matlab

fp = fopen('prtcl.txt', 'w');
if fp == -1
error('Не удалось открыть файл prtcl.txt для записи!');
endif
XX=load('dan_vuz.txt');
size(XX);
fprintf(fp, 'Size of XX: %s\n', mat2str(size(XX)));
X=XX(:,3:13);
R = corr(X);
[vect,lambda]=eig(X'*X);
Sobst=diag(lambda);
fprintf(fp, 'Eigenvalues:\n');
fprintf('Eigenvalue:\n');
for i = 1:length(Sobst)
fprintf(fp, '%f\n', Sobst(i));
fprintf('%f\n', Sobst(i));
end
fprintf(fp, '\n');
fprintf('\n');
SobMax = Sobst(end);
GlComp = vect(:, end);
Delt = 100*SobMax/sum(Sobst);
fprintf(fp, 'Delta=%d\n', round(Delt));
fprintf('Delta=%d\n', round(Delt));
Res = X * GlComp;
fprintf(fp,'Results\n');
for i = 1:size(XX, 1)
fprintf(fp, '%d %f \n', [XX(i, 1), Res(i)]');
fprintf('%d %f \n', [XX(i, 1), Res(i)]');
end
save res.mat Res -mat;
hist(Res, 20);
xlabel('Results');
ylabel('Number of Unis');
saveas(gcf,'Hist.jpg','jpg');
CorFin = corr(Res, XX(:,2));
fprintf(fp, 'Correlation of Results and Money = %f\n', CorFin);
fprintf('Correlation of Results and Money = %f\n', CorFin);