Removing Diagonal row and colum from Matrix

Discussion in 'MATLAB' started by skillz, Apr 24, 2007.

  1. skillz

    skillz Guest

    hi!

    How do i remove the first colum, 1st row and diagonal from a matrix
    i.e:

    if i had

    1 2 3 4 5 6
    2 1 3 3 3 3
    2 3 1 3 3 3
    2 3 3 1 3 3
    2 3 3 3 1 3

    therefore eliminating all the 1, 2, and the 3,4,5,6 in the top row
    only.
     
    skillz, Apr 24, 2007
    #1
    1. Advertisements

  2. skillz

    marky Guest

    %Remove first column:
    A = A:),2:end)

    %Remove first row:
    A = A(2:end,:)

    % One way to "remove diagonal"
    A = rand(5)
    B = A:));
    B(1:6:end) = [];
    reshape(B,4,5)
     
    marky, Apr 25, 2007
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.