Ad space (banner)
๐ŸŸฃJulia Lessons
Lesson 24 / 68

Two-dimensional arrays (tabular data)

This lesson covers matrices in Julia, with the aim of understanding the basics of the numerical work Julia is built for.

Writing [1 2 3; 4 5 6] — spaces between columns, semicolons between rows — creates a matrix. It is an intuitive literal that only a language built for numerical work would have. You reach into it as grid[row, column].

The sample code declares two rows by three columns as grid = [1 2 3; 4 5 6] and reaches a value with a comma-separated row and column, as in grid[2, 3]. Note grid[i, :], which takes a whole row out at once.

A common early stumble is that : (colon). grid[i, :] means "every column of row i" — a handy notation that comes up constantly in Julia matrix work.

In professional work, Julia was designed with linear algebra and scientific computing firmly in mind, and matrix arithmetic reads more naturally here than in most languages.

๐Ÿ“– Reference code
โœ๏ธ Your code
Type your code, then press "Run"

๐Ÿงช This site can't compile or run Julia directly, so it checks on the spot whether what you typed matches the reference code (scoring happens entirely in your browser โ€” nothing is sent anywhere).

Ad space (banner)
Ad space (in-article)