필터 지우기
필터 지우기

Matlab expanding matrix quickly

조회 수: 1 (최근 30일)
Niels de Vries
Niels de Vries 2018년 8월 3일
편집: Fangjun Jiang 2018년 8월 3일
Hey all,
Suppose you have as input: matrix A = [10 9 8] and some factor X = 3
As output i would like to obtain: R = [10 10 10 9 9 9 8 8 8]
I am wondering if there are better (faster) solutions then my solution below:
R = zeros(1,length(A)*X);
for i =1:X
R(1+length(A)*(i-1):1:length(A)*i) = A(i);
end

채택된 답변

Fangjun Jiang
Fangjun Jiang 2018년 8월 3일
편집: Fangjun Jiang 2018년 8월 3일
reshape(repmat(A,X,1),1,[])

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by