Generate a increasing increment array

7 ビュー (過去 30 日間)
Andy Lau
Andy Lau 2018 年 10 月 12 日
回答済み: Image Analyst 2018 年 10 月 13 日
Hi,
I was wondering how to generate array as follow
1 4 9 16 25
As you can see, the differences between them is
3 5 7 9
of increasing order. I was wondering how to do that without using any loop?
Thanks Andy

採用された回答

Walter Roberson
Walter Roberson 2018 年 10 月 12 日
1 + cumsum(3:2:9)

その他の回答 (1 件)

Image Analyst
Image Analyst 2018 年 10 月 13 日
Not sure what the rule is (actually I guess Walter figured it out since you accepted it), but here's another way:
>> v = (1:5).^2

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by