- using 1 value, which will result in that many replications in the first two dimensions (rows and cols)
- using 1 vector, which specifies the number of replications in each dimension (e.g. [1 1 3] will replicate a value/vector/matrix into the 3rd dimension, useful for going from greyscale to RGB images)
- splitting the vector over separate arguments
1 ビュー (過去 30 日間)
Rik 2017 年 5 月 30 日
Have you even considered looking at the documentation? It really helps answering your question.
Looking at the documentation, I could find how supplying a vector as the second argument would work, but I get a warning. "repmat(A,M,N) where M or N is a row vector will return an error in a future release. Use repmat(A,[M,N]) instead." This hints at what is happening: it concatenates all inputs into 1 vector.
The first argument is the scalar/vector/matrix that you want to replicate. Then you have 3 options:
Knowing this it is obvious why your results are what they are. The first replicates a 1x9 vector (1:9) 6 times in the first dimensions (the rows), so you get a 6x9. The second replicates a scalar (so 1x1), using [1:9,1] as the repetition scheme, so the result is a 1x2x3x4x5x6x7x8x9x1 matrix, which is an 9-dimensional matrix (as any trailing x1 can be ignored).