In MATLAB, you create a vector by enclosing the elements in square brackets like so:

 x = [1 2 3 4]

Commas are optional, so you can also type

 x = [1, 2, 3, 4]

Create the vector

 x = [1 2 3 4 5 6 7 8 9 10]

There's a faster way to do it using MATLAB's colon notation.

Solution Stats

93409 Solutions

53403 Solvers

Last Solution submitted on Jul 09, 2026

Last 200 Solutions

Problem Comments

Solution Comments

Show comments
Loading...

Problem Recent Solvers53403

Suggested Problems

More from this Author96

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!