For a very large matrix of (1500000, 6) I wish to change the first 10 values in column 1 to 1, the next 10 values to 2, the next 10 to 3, etc.
Using for example:
X = randi([0,1],[1500000,6]);
To create the table.

 채택된 답변

Tommy
Tommy 2020년 4월 5일

0 개 추천

Try this:
N = 1500000;
X = randi([0,1],[N,6]);
i = 1:N/10;
X(:,1) = repelem(i,10);

댓글 수: 1

RickJ
RickJ 2020년 4월 5일
That's it! Incredible, thank you so much!!!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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

제품

질문:

2020년 4월 5일

댓글:

2020년 4월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by