How to create a vector that repeats 5 values per increment in a for loop?
조회 수: 5 (최근 30일)
이전 댓글 표시
I have a vector I am trying to create that contains the numbers 100-1000 and is incremented by 50. But I want the vector to contain 5 of each increment like [100,100,100,100,100,150,150,150,150,150,200,200,200,200,200,.......,1000,1000,1000,1000,1000]. I created the for loop below but it creates a matrix with 5 rows of 1000. How can I change this for loop to get the vector described above?
for ii=100:50:1000
for j=1:19
x = zeros(1,5)+ii;
ratesX(:,j) = x;
end
end
댓글 수: 0
채택된 답변
추가 답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!