cjm2671
cjm2671

Reputation: 19486

How do I stack matrices in KDB?

I'm trying to insert a new row at the beginning of a matrix, but the result is inserting my row vector rotated:

a: (.7 .3; .1 .2)
b: (.5 .5)

b, a

0.5
0.5
0.7 0.3
0.1 0.2

Intended result:

0.5 0.5
0.7 0.3
0.1 0.2

What am I doing wrong?

Upvotes: 0

Views: 93

Answers (2)

SJT
SJT

Reputation: 1097

Or you can make b a matrix. Join on matrices works the way you expect.

q)(1 2#b),a
0.5 0.5
0.7 0.3
0.1 0.2

Upvotes: 2

CalumStackenzie
CalumStackenzie

Reputation: 121

(enlist b), a gives the result you want. It helps to think of a as being made from nested lists, hence any new rows should be of this form as well.

Upvotes: 3

Related Questions