1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Concatenating 2D array

  1. Jun 13, 2014 #1

    Maylis

    User Avatar
    Gold Member

    1. The problem statement, all variables and given/known data
    I'm working on problem 1, specifically part (d) in the attached PDF file. I will show my code for (a) - (c) so you can see where I am coming from


    2. Relevant equations



    3. The attempt at a solution

    (a)
    Code (Text):
      A1 = [1.3 5.2; 7.4 3.8; 9 2]

    A1 =

        1.3000    5.2000
        7.4000    3.8000
        9.0000    2.0000
    (b)
    Code (Text):
     
    A1(2)

    ans =

        7.4000
     
    (c)
    Code (Text):
    B = [1 1 1];
    A3 = [A1 B']

    A3 =

        1.3000    5.2000    1.0000
        7.4000    3.8000    1.0000
        9.0000    2.0000    1.0000
     
    (d)
    I don't know how to add a row into the array for any given row. I know if I wanted to add for example [0 0] to the end of the row

    Code (Text):
     
    C = [0 0]

    C =

         0     0

    A4 = [A1; C]

    A4 =

        1.3000    5.2000
        7.4000    3.8000
        9.0000    2.0000
             0         0
     
    but I just need to move that [0 0] into the second row
     

    Attached Files:

    Last edited: Jun 13, 2014
  2. jcsd
  3. Jun 14, 2014 #2
    I think you have to use [xxx; C ; yyy] where xxx and yyy extract the relevant rows from A1.

    Also the problem told you to use the zeros command, which you could put in place of making the intermediate matrix C.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted