How to create a vector of increasing and decreasing increments with linspace?

I need to create a vector b = 1 2 3 4 5 6 7 8 9 10 9 8 7 6 5 4 3 2 1 (19 elements) using linspace function. How would I create this with only one command?

4 Comments

This sounds like a strange requirement. What is the full text of this homework assignment?
Clearly homework, because requiring the use of linspace is artificial. And there is no need to use linspace either. You don't even need to use brackets, if you want to be tricky. For example...
10 - abs(-9:9)
Or, perhaps this one?
1 + abs(mod(0:18,10) - 8*floor((0:18)/10))
Not at all hard to find multiple ways to do this homework problem. That linspace was not used in these ways seems irrelevant. And really, who needs linspace anyway? Unless it is for homework.

Sign in to comment.

Answers (0)

Categories

Products

Tags

Asked:

on 14 Sep 2019

Commented:

on 14 Sep 2019

Community Treasure Hunt

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

Start Hunting!