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

Create 1D and 2D arrays

In this exercise let's briefly review how to create a 1D array, or a vector, before moving on to 2D arrays (matrices). A quick way to create a vector is to use the square bracket notation, like so:

my_vector = []

These square brackets contain the sequence of values that you wish to store in the vector.

The syntax to create a 2D array is very similar, again using square bracket notation. However, we also use the semicolon ; notation to denote a new row.

my_matrix = [1 2 ; 3 4]

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

Intermediate Julia

ดูคอร์ส

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

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

# Create a vector containing the values one through six
my_array = ____
แก้ไขและรันโค้ด