Skip to content

Instantly share code, notes, and snippets.

@danlurie
Created May 3, 2020 01:28
Show Gist options
  • Save danlurie/4803a7003fdd691722e494a4b7c9be96 to your computer and use it in GitHub Desktop.
Save danlurie/4803a7003fdd691722e494a4b7c9be96 to your computer and use it in GitHub Desktop.
%create the design matrix, Mi
M = nan(26,3);
Mi = nan(26,6);
Morig = nan(26,3);
i = 1;
unit = [1 0 -1];
for c = unit(1:3)
for b = unit(1:3)
for a = unit(1:3)
M(i,:) = [a b c];
Morig(i,:) = [a b c];
if sum(abs(M(i,:)))' == 2
M(i,:) = M(i,:).*[(1/sqrt(2)) (1/sqrt(2)) (1/sqrt(2))];
elseif sum(abs(M(i,:)))' == 3
M(i,:) = M(i,:).*[(1/sqrt(3)) (1/sqrt(3)) (1/sqrt(3))];
end
Mi(i,:) = [M(i,1)^2 2*M(i,1)*M(i,2) 2*M(i,1)*M(i,3) M(i,2)^2 2*M(i,2)*M(i,3) M(i,3)^2]; %normalize
i = i+1;
[a;b;c];
end
end
end
Mi(14,:) = []
Morig(14,:) = []
T = inv(Mi' * Mi) * Mi'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment