Appending element by element left half matrix to right half

Home Forums Matlab Appending element by element left half matrix to right half

This topic contains 1 reply, has 2 voices, and was last updated by  cK 9 years, 10 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #500

    pankaj kumar
    Participant

    I have a 4X4 square matrix

    1 2 3 4
    5 6 7 8
    9 10 11 12
    13 14 15 16

    which I like to convert into 4×2 matrix such as left half of matrix append to right half element by element such as
    (3+1) (4+2)
    (5+7) (8+6)
    (9+11) (12+10)
    (15+13) (16+14)
    one way I can do through using loop, May I know matlab in built function or efficient way to do this conversion?

    #502

    cK
    Keymaster

    [sum(x(:,1:2:end),2), sum(x(:,2:2:end),2)]
    where x is the matrix

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.