Hi!
I think this is very easy to solve, but I simply dont know what is the easiest way. Let's say I have a vector:
A=[1 2 3]
Now I want to repeat this column into a Matrix
B=[1 2 3; 1 2 3; 1 2 3]
How do I go about this?
Thanks in advance.
Alexander

 채택된 답변

Birdman
Birdman 2018년 3월 22일

2 개 추천

B=repmat(A,3,1)

추가 답변 (1개)

Jan
Jan 2018년 3월 22일
편집: Jan 2018년 3월 22일

1 개 추천

Or:
B = A(ones(1,3), :)
This is what happens inside repmat also. It has slightly less overhead, but I'd prefer repmat instead - for unclear reasons.

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

질문:

2018년 3월 22일

편집:

Jan
2018년 3월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by