How to reshape and repeat at the same time.
Ältere Kommentare anzeigen
Hi guys, I have the following data
data= [1 3 7 9 2 5]
and I want the data to be as a matrix (2*6)
newdata=1 1 7 7 2 2
3 3 9 9 5 5
Please help me, and thanks in advance.
Akzeptierte Antwort
Weitere Antworten (1)
Roger Stafford
am 2 Jan. 2017
newdata = reshape(repmat(reshape(data,2,[]),2,1),2,[]);
3 Kommentare
Bahaa Algebory
am 4 Jan. 2017
Roger Stafford
am 5 Jan. 2017
It is much easier to get ‘finaldata’ directly from ‘data’:
finaldata = reshape(repmat(data,2,1),1,[]);
Bahaa Algebory
am 5 Jan. 2017
Bearbeitet: Bahaa Algebory
am 5 Jan. 2017
Kategorien
Mehr zu Cell Arrays finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!