generating a sequence 1,2,3,4,....,n

118 views (last 30 days)
Rabeya
Rabeya on 21 Apr 2012
Answered: Arsal noor on 22 Oct 2020
Without using a for loop, how can I generate an index 1,2,3,...,n?

Accepted Answer

R.U.F.
R.U.F. on 21 Apr 2012
vector=[1:stepsize:n] if the stepsize =1 as in your case, you can disregard it
  1 Comment
Jan
Jan on 22 Apr 2012
Following the mlint suggestion, you can omit the square brackets: "1:n"

Sign in to comment.

More Answers (1)

Arsal noor
Arsal noor on 22 Oct 2020
X = [1 2 3 4]

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

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

Start Hunting!