# Math Help - repmat command

1. ## repmat command

Let say i have a 3x3 array which made up of different numbers. If i am asked to use repmat command to replace the first row by -2's, how can I do that?
Is it possible to make it in a single step?

2. Originally Posted by elliotyang
Let say i have a 3x3 array which made up of different numbers. If i am asked to use repmat command to replace the first row by -2's, how can I do that?
Is it possible to make it in a single step?
Why using repmat?

Code:
A=rand(3,3);
A(1,:)=-2*ones(1,3);
does the job perfectly well (and in one line).

Though:

Code:
A(1,:)=repmat(-2,1,3);
will also do the job.

CB

3. Well, I must use the repmat command for that question. Anyway, I just figure out how to do it. A(1:1, =repmat(-2,1,3)