1
votes

How do I slice a Julia matrix so that I get the first x rows?

I've tried

slicedMatrix = matrix[1 : x ; :]

but I keep getting this error

ERROR: LoadError: MethodError: no method matching typed_vcat(::Array{Float64,2}, ::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}, ::Colon)

Using commas instead of semicolons doesn't help.

1
"Using commas instead of semicolons doesn't help." Using a comma instead of a semicolon is the answer.mbauman

1 Answers

4
votes

Assuming x is defined it should just be slicedMatrix = matrix[1 : x, :].