How to create a vector of increasing and decreasing increments with linspace?
7 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
John D'Errico
2019 年 9 月 14 日
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.
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!