Results 1 to 2 of 2

Math Help - Referencing matrix cells in matlab

  1. #1
    Newbie
    Joined
    Mar 2009
    Posts
    11
    Awards
    1

    Referencing matrix cells in matlab

    Hello, im having trouble with this matrix (shown below). What im trying to do is make a row vector of all the values along the row number defined by j, except for the main diagonal. So that in effect, each value is taken as it is shown in the matrix, apart from the diagonal values.

    M = [2 -1 -0.5 0 0 0 0 0;-1 4 -1 0 0 0 0 0; -0.5 0 2 -1 -0.5 0 0 0; 0 -1 -1 4 0 -1 0 0; 0 0 -0.5 0 2 -1 -0.5 0; 0 0 0 -1 -1 4 0 -1; 0 0 0 0 -1 0 3 -1; 0 0 0 0 0 -1 -0.5 3]

    for j=1:L
    M(j,1:L)
    end
    in effect what im am trying to command is
    M(j,1: (j-1) && (j+1):L)
    so that it misses out the j column.
    where L is defined as the length of the matrix

    Any help would be fantastic
    Last edited by p123nky; March 25th 2009 at 02:18 PM.
    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 p123nky View Post
    Hello, im having trouble with this matrix (shown below). What im trying to do is make a row vector of all the values along the row number defined by j, except for the main diagonal. So that in effect, each value is taken as it is shown in the matrix, apart from the diagonal values.



    in effect what im am trying to command is


    so that it misses out the j column.
    where L is defined as the length of the matrix

    Any help would be fantastic
    [M(j,1:j-1),M(j,j+1:L)]

    CB
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. calculating grid cells in move between cells
    Posted in the Algebra Forum
    Replies: 15
    Last Post: January 21st 2011, 12:38 PM
  2. matlab matrix help
    Posted in the Math Software Forum
    Replies: 3
    Last Post: May 18th 2010, 12:21 AM
  3. Dirichlet cells construction
    Posted in the Advanced Applied Math Forum
    Replies: 0
    Last Post: May 17th 2009, 10:21 AM
  4. Matlab ( Matrix )
    Posted in the Math Software Forum
    Replies: 2
    Last Post: April 6th 2009, 01:32 AM
  5. Matlab help ........Matrix
    Posted in the Math Software Forum
    Replies: 0
    Last Post: April 4th 2009, 06:05 AM

Search Tags


/mathhelpforum @mathhelpforum