How can I replicate this matrix
이전 댓글 표시
I have F= 20x12 matrix and I want to get F2 =62x12 matrix in such away that The each element of F(20X12)is replicated by 3 and the last value has to be replicated 5 times so as to have 62x12 data
here is the matrix I worked upon and failed
for k =size(F,1);
a=repmat(F,3,1);
F2=[a(:);ones(2,1)*a(end)]
end;
but couldn't succeed..any help is highly appreciated
채택된 답변
추가 답변 (2개)
Walter Roberson
2012년 12월 18일
F2 = [repmat(F, 3, 1), F([end end], :)];
댓글 수: 2
Ede gerlderlands
2012년 12월 18일
Walter Roberson
2012년 12월 18일
F2 = [kron(F, ones(3, 1)); F([end end], :)];
Daniel Shub
2012년 12월 18일
I like questions that can be answered with one-liners ...
F([reshape(repmat(1:length(F), 3, 1), 3*length(F), 1); repmat(length(F), 2, 1)], :)
카테고리
도움말 센터 및 File Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!