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

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
@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 Exchange에서 Programming에 대해 자세히 알아보기

질문:

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