Created
April 2, 2014 16:46
-
-
Save kmader/9937986 to your computer and use it in GitHub Desktop.
Calculate Alignment from Orientation Data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
aligndata=importdata('align_a.csv',',',1) | |
disp(aligndata.colheaders) | |
%% parse the data in matlab | |
% A tiny piece of code to find which column the given header is in | |
findColumn=@(idstrut,colName) find(not(cellfun('isempty',strfind(idstrut.colheaders,['"' colName '"'])))); | |
% a function to return all of the data in that column | |
getColumn=@(idstrut,colName) idstrut.data(:,findColumn(idstrut,colName)); | |
%% show the data | |
figure(1) | |
subplot(1,2,1); | |
plot(getColumn(aligndata,'x'),getColumn(aligndata,'y'),'r.') | |
title('Point Location') | |
subplot(1,2,2); | |
xvec=getColumn(aligndata,'xv'); | |
yvec=getColumn(aligndata,'yv'); | |
quiver(zeros(size(xvec)),zeros(size(yvec)),xvec,yvec);% ,'b.') | |
title('Orientation') | |
pause(0.5) | |
%% calculate the alignment tensor | |
% alignment covariance matrix | |
acovmat=cov([xvec yvec]); | |
[eigvecs,eigvals]=eig(acovmat); | |
eigvals=diag(eigvals); | |
disp(['Alignment ' num2str((max(eigvals)-min(eigvals))/max(eigvals)*100) '%']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment