Skip to content
Snippets Groups Projects
Commit 24ddd6ed authored by Marco Ratto's avatar Marco Ratto
Browse files

cheaper execution for pairwise correlations

parent 1bc6da86
No related branches found
No related tags found
No related merge requests found
function co = cosn(H); function [co, b, yhat] = cosn(H);
% function co = cosn(H); % function co = cosn(H);
% computes the cosine of the angle between the H(:,1) and its % computes the cosine of the angle between the H(:,1) and its
...@@ -30,9 +30,14 @@ X = H(:,2:end); ...@@ -30,9 +30,14 @@ X = H(:,2:end);
% y = H(:,1); % y = H(:,1);
% X = H(:,2:end); % X = H(:,2:end);
yhat = X*(X\y); if size(X,2)==1;
b=1;
else
b=(X\y);
end
yhat = X*b;
if rank(yhat), if rank(yhat),
co = y'*yhat/sqrt((y'*y)*(yhat'*yhat)); co = abs(y'*yhat/sqrt((y'*y)*(yhat'*yhat)));
else else
co=0; co=0;
end end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment