How do I create the follow array: [0 0 0 ... 0 1 2 ... 100 100 100], where there are 100 zeros on the left and 100 100's on the right? I must use the colon operator.

4 views (last 30 days)
For previous questions I just used, for example, [0:0.01:1], to create the array from 0 to 1 using increments of 0.01. I just do not know how to include multiple numbers before and after the beginning and end terms.
  2 Comments
Jan
Jan on 31 Aug 2017
Please mention it, when you post a homework question. This requires a different kind of answering.
Stephen23
Stephen23 on 31 Aug 2017
Edited: Stephen23 on 31 Aug 2017
@Sebastiano Inturrisi: rather than wasting time asking questions about how to use basic MATLAB, you should simply do the Introductory Tutorials, and learn how to concatenate arrays yourself:
Also reading the documentation is a good idea: zeros, ones, etc.

Sign in to comment.

Accepted Answer

Jan
Jan on 31 Aug 2017
Use the square brackets for a concatenation of arrays:
[1, 3, 5, 4]
or
a = 1:5;
b = [a, a]
Now create the 3 needed parts of the result and join them.
Please note that such basic questions are explained exhaustively in the Getting Started chapters of the documentation. It is efficient to read them, while asking the very basics in the forum is slower, because you have to wait until someone rephrases the information given in the documentation already.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!