เริ่มต้นใช้งานเริ่มต้นใช้งานได้ฟรี

Index and slice a 2D array

Now that you're familiar with how to create a 2D array, let's practice indexing and slicing 2D arrays to return specific elements.

Remember that we use the square bracket notation to index a 2D array, like so:

my_array[row, column]

We can also use getindex to index into an array, by passing the array, the row, and the column into the function.

To select an entire row or an entire column, use the colon : operator.

แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร

Intermediate Julia

ดูคอร์ส

แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ

ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์

# Create a 3x3 array
my_array = ____
แก้ไขและรันโค้ด