Creating a matrix with repeating the same numbers.

1 Ansicht (letzte 30 Tage)
Jagadesh Rao
Jagadesh Rao am 28 Okt. 2014
Kommentiert: dpb am 2 Nov. 2014
Hi, i am back with one more question.
If 't' is any variable, let's keep t=10
i need a matrix
A=[1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11]
if t=11, i need
A=[1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12]
Any help will be appreciated. this is because of my project.

Akzeptierte Antwort

dpb
dpb am 28 Okt. 2014
Bearbeitet: dpb am 29 Okt. 2014
Not a lot of work there...
v=repmat([2:t],2,1);
A=[1 v(:).' t+1];
  4 Kommentare
dpb
dpb am 2 Nov. 2014
Looks like Roger S was already by...

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by