i have following matrix a = [1.00 2.00; 3.00 4.00] , need convert vector of vectors follows:
a1 = [1.00; 3.00] a2 = [2.00; 4.00]
any ideas?
tl;dr
can elegantly created list comprehension:
a = [a[:,i] in 1:size(a,2)] explanation:
this converts a indexed a[1,2] indexed a[2][1], asked.
here i'm assigning directly a, seems me had in mind. but, if code unambiguous! it's not idea have same-named variables represent different things @ different points in code.
note: if reversal of row / column order in indexing isn't order had in mind, , you'd prefer a[1,2] indexed a[1][2], perform list comprehension 'per row' instead, i.e.
a = [a[i,:] in 1:size(a,1)]
Comments
Post a Comment