Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Is there a way for creating n number of new rows from one row?

조회 수: 1 (최근 30일)
CarenCaren
CarenCaren 2016년 5월 19일
마감: MATLAB Answer Bot 2021년 8월 20일
Let my matrix be
a=[1 2 3 4
5 6 7 8]
Then I want to create n=8 new rows from the first row according to this logic.
newrow_1=firstrow +/- (rand()/k)* firstrow
And it goes on newrow_2.... till newrow_8.

답변 (1개)

Ahmet Cecen
Ahmet Cecen 2016년 5월 19일
편집: Ahmet Cecen 2016년 5월 19일
A much more robust version of that reference answer, especially if you need to repeat every row the same amount of times, and you have a lot of rows:
b = repmat(a',[4,1]);
c = reshape(b,[4,8])';
or:
b = repmat(a',[numberoftimestorepeat,1]);
c = reshape(b,[size(a,2),size(a,1)*numberoftimestorepeat])'

Community Treasure Hunt

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

Start Hunting!

Translated by