Skip to content

Instantly share code, notes, and snippets.

@tiborsimon
Created February 16, 2015 11:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tiborsimon/ba174f57d62071f26aa1 to your computer and use it in GitHub Desktop.
Save tiborsimon/ba174f57d62071f26aa1 to your computer and use it in GitHub Desktop.
Access upper triangular matrix elements stored in a single row vector - MATLAB implementation - http://tibor-simon.com/programming/access-upper-triangular-matrix-elements-stored-in-a-single-row-vector/
%First create a small function that
function [ l ] = ij2l( i, j, n )
%IJ2L Upper Triangle Matrix Coordinates to Single Row Index
l = j;
for k=1:(i-1)
l = l + (n-k);
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment