how to create an array from a given array with the following criteria.
조회 수: 6 (최근 30일)
이전 댓글 표시
Say given array is [1 2 3]. I want to create an array with the elements [1 2 3 4 5 2 3 4 5 6 3 4 5 6 7],
In others terms I want to create an array [1:1+4 2:2+4 3:3+4]
I do not want to use for loops as that slows my code considerably.
댓글 수: 0
채택된 답변
추가 답변 (1개)
Ameer Hamza
2020년 6월 12일
An alternative solution using automatic array expansion
a = 1:3;
b = reshape(a + (0:4)', [], 1);
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!