Create new matrix based on an existing one
조회 수: 2 (최근 30일)
이전 댓글 표시
I have a big matrix. Now I want to create a new matrix that takes the first value in each column and changes the following 11 values with the fist value. Then I want to take the value of the 13th row for each column and put in in the following 11 rows for each column.
An example for a column:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
I would like to change it to:
1 1 1 1 1 1 1 1 1 1 1 1 13 13 13 13 13 13 13 13 13 13 13 13
This would be an example for a small column. My matrix has the dimension of 253X7690.
Thank you for your help.
댓글 수: 0
채택된 답변
Jan
2017년 3월 6일
A = rand(253, 7690);
B = A(1:12:end, :); % Take every 12th row
C = repelem(B, 12, 1); % Needs Matlab >= 2015a
With older Matlab versions:
Index = repmat(1:12:size(A, 1), 12, 1);
C = A(Index(:), :);
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Entering Commands에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!