new to matlab, matrix question
Show older comments
I'm very new to Matlab and want to create a matrix that is 2xn where the first column is all 1's and the second column increments 1-100. I know how to write a for loop to get an incrementing vector and I know how to create a matrix of all ones, but I can't figure out a for loop that will retrain the 1 in the first column. EG) I want my matrix A to look like [1,1;1,2;1,3;...;1,n].
Accepted Answer
More Answers (1)
Darin McCoy
on 11 Feb 2014
n = 100;
[ones(n,1) (1:n)'];
Categories
Find more on Loops and Conditional Statements 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!