row that increases more every element
조회 수: 6 (최근 30일)
이전 댓글 표시
Hello,
I was wondering how I would make an array that increases more every element
for example:
given lets say n=randi([10 20], 1);
how would i have vect1 = 9, 16, 25, 36, ... n: so bascially increasing by +2 every element starting at 9
댓글 수: 3
Walter Roberson
2022년 5월 20일
Your example increases by 9 each time, not by 2?
Are you wanting to start with the fixed value 9 and use the random number to determine the number of terms??
채택된 답변
추가 답변 (1개)
DGM
2022년 5월 20일
Here's my guess:
A = randi([10 20], 1,10)
B = cumsum(A) % cumulative sum of A
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!