How to create a vector with certain numbers?

How is it possible to create a vector where, for example, the first 10 positions have the value 20, the second 10 positions the value 30, and the third 10 positions value of 40 and so on, until a the end of a certain vector. In the end I want to do this for a vector of almost 1000000 row. So it should not be done manually, but maybe with a loop?

 채택된 답변

Guillaume
Guillaume 2017년 11월 1일
편집: Guillaume 2017년 11월 1일

0 개 추천

Simply
repelem(1:10:1000000, 10)'

추가 답변 (1개)

Bjorn Gustavsson
Bjorn Gustavsson 2017년 11월 1일

0 개 추천

something likethis would do it for you;
nMax = 1e6;
Vals = 20:10:(10*(nMax+1)); % whatever values you want
[X] = meshgrid(Vals,1:10);
X = X(:); % Or its transpose.
HTH

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

제품

질문:

2017년 11월 1일

댓글:

2017년 11월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by