How to create a sequence

Hi, I am trying to create a sequence of values, where the nth term is 1/(3n+2). so if I want 10 values, the desired output would be [1/2 1/5 1/8 1/11 and so on until 1/20]. I need to use this vector for my nest function,.

回答 (1 件)

David Hill
David Hill 2019 年 9 月 12 日

0 投票

n=1:10;
x=1/(3*n+2);
You just make a vector n (1:10) and plug it into the equation (x is your desired vector).

3 件のコメント

David Hill
David Hill 2019 年 9 月 12 日
x=1./(3*n+2);
forgot the dot!
Chris
Chris 2022 年 8 月 31 日
編集済み: Chris 2022 年 8 月 31 日
Use n = 0:10; if you want to start with 1/2 as your first term
John D'Errico
John D'Errico 2022 年 8 月 31 日
@Chris - But then if you want EXACTLY 10 terms starting at 1/2, it would be
n = 0:9;
0:10 would create 11 terms.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeProgramming についてさらに検索

質問済み:

2019 年 9 月 12 日

コメント済み:

2022 年 8 月 31 日

Community Treasure Hunt

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

Start Hunting!

Translated by