mooglin
mooglin

Reputation: 534

Julia matrix slicing

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.

Upvotes: 2

Views: 600

Answers (1)

Oscar Smith
Oscar Smith

Reputation: 6388

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

Upvotes: 5

Related Questions