How to create a 24x2 matrix with 0:23 as the first column and 1 as the second column?

1 view (last 30 days)
I want to create a matrix that has 24 rows and 2 columns.
The elements on the first column are 0,1,2.....23 and the elements on the second column is all 1.
Is there a faster way to do it other than type them all out?
Thanks!

Accepted Answer

Image Analyst
Image Analyst on 18 Nov 2014
This will do that:
m = ones(24,2);
m(:,1) = 0:23
(I hope I didn't just do your homework for you!)

More Answers (0)

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!