Concatenating vectors

Hello colleagues,
I have a little question. I want to build a matrix in Julia 7.0, where is a concatenation of several vectors of same length. I use the code:
A = rand(10,10)
B = %a empty matrix
for i=1:2:10
B = [B;A[i,:]] %B is the matrix whose line i is from A, where i is odd
In Julia 0.6.4, the above code is ok. But in version 7.0 not run. The error is:
ArgumentError: number of columns of each array must match (got (1, 10))

Anyone could help me?

To fix the dimension mismatch, you can initialize B with zeros(0,10) (so it’s 0 rows and 10 columns), and use A[i:i,:] in place of A[i,:] inside the loop (to get a 1×10 row vector).
But it’s easier to just do

B = A[1:2:10,:]

Thank you very much, colleague!!!

There’s something very strange about your code snippet, btw. Your comments use % which should not work, since the julia character for comments are #, and the assignment to B has some weird character that I cannot even copy, it seems to be an image of some sort.

It’s great that you got the help you needed, but for future reference, it is preferable if you can provide a full example that can be copied and run, and also that you wrap your example code in triple backticks, as explained here: Please read: make it easier to help you


Thank you very much for attention.

A bit OT, but it’s an empty check box (code “[ ]” interpreted as markdown):

[ ]