Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • transpose a row to a column

    c1 c2 c3 c4 c5
    3 5 4 2 2
    7 5 1 6 1
    4 7 5 6 5
    10 15 17 0 0
    This is an example matrix that I have.
    And I'd like to transepose the 4th row to the 6the column(that is c6)
    Always (4th row X 4the column)=(4the row X 5th column)=0
    so I'd like to make below matrix..
    c1 c2 c3 c4 c5 c6
    3 5 4 2 2 10
    7 5 1 6 1 15
    4 7 5 6 5 17
    How can I do this?
    Please help me!!

  • #2
    I'd recommend taking a look at the help file for Mata's subscripting.
    Code:
    help m2_subscripts
    In the meantime, you could try something like the following. Begin at the "Begin here" comment.

    .ÿversionÿ14.1

    .ÿ
    .ÿlocalÿlinesizeÿ`c(linesize)'

    .ÿsetÿlinesizeÿ78

    .ÿ
    .ÿmata:
    -------------------------------------------------ÿmataÿ(typeÿendÿtoÿexit)ÿ----
    :ÿmataÿsetÿmatastrictÿon

    :ÿ
    :ÿAÿ=ÿ(3,ÿ5,ÿ4,ÿ2,ÿ2ÿ\
    >ÿÿÿÿÿÿ7,ÿ5,ÿ1,ÿ6,ÿ1ÿ\
    >ÿÿÿÿÿÿ4,ÿ7,ÿ5,ÿ6,ÿ5ÿ\
    >ÿÿÿÿÿÿ10,ÿ15,ÿ17,ÿ0,ÿ0)

    :ÿ
    :ÿ/*
    >ÿÿÿBeginÿhere
    >ÿ*/
    :ÿAÿ=ÿA[(1..3),ÿ.],ÿA[4,ÿ(1::3)]'

    :ÿ
    :ÿA
    ÿÿÿÿÿÿÿÿ1ÿÿÿÿ2ÿÿÿÿ3ÿÿÿÿ4ÿÿÿÿ5ÿÿÿÿ6
    ÿÿÿÿ+-------------------------------+
    ÿÿ1ÿ|ÿÿÿ3ÿÿÿÿ5ÿÿÿÿ4ÿÿÿÿ2ÿÿÿÿ2ÿÿÿ10ÿÿ|
    ÿÿ2ÿ|ÿÿÿ7ÿÿÿÿ5ÿÿÿÿ1ÿÿÿÿ6ÿÿÿÿ1ÿÿÿ15ÿÿ|
    ÿÿ3ÿ|ÿÿÿ4ÿÿÿÿ7ÿÿÿÿ5ÿÿÿÿ6ÿÿÿÿ5ÿÿÿ17ÿÿ|
    ÿÿÿÿ+-------------------------------+

    :ÿ
    :ÿend
    ------------------------------------------------------------------------------

    .ÿ
    .ÿsetÿlinesizeÿ`linesize'

    .ÿ
    .ÿexit

    endÿofÿdo-file


    .

    Comment

    Working...
    X