Results 1 to 3 of 3

Math Help - repmat command

  1. #1
    Junior Member
    Joined
    Feb 2009
    Posts
    28

    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?
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by elliotyang View Post
    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
    Last edited by CaptainBlack; February 15th 2009 at 01:13 AM.
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Junior Member
    Joined
    Feb 2009
    Posts
    28
    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)
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. rref command
    Posted in the Calculators Forum
    Replies: 1
    Last Post: May 14th 2011, 10:08 AM
  2. [SOLVED] Left hand alignment in the matrix command and array command
    Posted in the LaTeX Help Forum
    Replies: 8
    Last Post: May 3rd 2011, 03:31 PM
  3. Latex command!
    Posted in the LaTeX Help Forum
    Replies: 2
    Last Post: December 17th 2010, 12:04 PM
  4. MATLAB: The cat command
    Posted in the Math Software Forum
    Replies: 4
    Last Post: July 13th 2010, 02:32 PM
  5. command for..?
    Posted in the LaTeX Help Forum
    Replies: 9
    Last Post: November 2nd 2007, 06:40 AM

Search Tags


/mathhelpforum @mathhelpforum