Skip to content

Instantly share code, notes, and snippets.

@tiborsimon
Created February 16, 2015 12:00
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/8beb75302f86c4962360 to your computer and use it in GitHub Desktop.
Save tiborsimon/8beb75302f86c4962360 to your computer and use it in GitHub Desktop.
Access upper triangular matrix elements stored in a single row vector - testing in MATLAB implementation - http://tibor-simon.com/programming/access-upper-triangular-matrix-elements-stored-in-a-single-row-vector/
%% Testing th ij2l function
%% Let the upper trinagle matrix be
%
% | 1 2 3 |
% A = | 4 5 |
% | 6 |
%
% We want to index the second row, last element:
%
% | 1 2 3 |
% A = | 4(5)|
% | 6 |
n = 3;
i = 2;
j = 3;
l = ij2l(i,j,n);
v = [1 2 3 4 5 6];
v(l)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment