0

I want to add the same data in different lines using Matlab. In my first version, I copied the data as shown in the code below. Is there a better way to do that?

data=[-5:1:14;-5:1:14;-5:1:14;-5:1:14;]

answer:

    -5    -4    -3    -2    -1     0     1     2     3     4     5     6     7     8     9    10    11    12
    -5    -4    -3    -2    -1     0     1     2     3     4     5     6     7     8     9    10    11    12
    -5    -4    -3    -2    -1     0     1     2     3     4     5     6     7     8     9    10    11    12
    -5    -4    -3    -2    -1     0     1     2     3     4     5     6     7     8     9    10    11    12
Ba360
  • 44
  • 7

1 Answers1

1

You can try repmat

repmat(-5:14,4)

or kron

kron(-5:14,ones(4,1))
ThomasIsCoding
  • 96,636
  • 9
  • 24
  • 81