Results 1 to 3 of 3

Math Help - Find max in a column of a matrix for antidiagonal help

  1. #1
    Junior Member
    Joined
    Feb 2008
    Posts
    64

    Find max in a column of a matrix for antidiagonal help

    this is how i have managed to get a user to input a matrix

    Code:
    clear all
    disp('Input size of matrix you would like to create (NxN)')
    N=input('N=');
    for i=1:N
        for j=1:N
            a(i,j)=input(strcat('a(',int2str(i),',',int2str(j),')='));
        end
    end
    disp('Matrix before modification')
    a
    i=1
    j=1
    a(i,j)=Max;
    Nmax=1,1;
    for i=1
        for j=1:N
           if a(i,j)>Max
             Max=a(i,j);
             Nmax=i,j;
           end
           if a(Nmax)=Max
              a(i,j)=zeros
           end
        end
        k=(j+1)
        i=(i+1);
    end
    [/SIZE][/FONT]i would like to know how to find out if the antidiagonal of each column is tha maximum of that column and then be able to set a condition if the result is true

    i have edited the code abit more but its not workign and i dont know how to fix it or if im even goign about it the right way
    Last edited by CaptainBlack; February 17th 2010 at 01:48 AM. Reason: Indenting correctly will make the structure clearer
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Code:
    clear all
    disp('Input size of matrix you would like to create (NxN)')
    N=input('N=');
    for i=1:N
        for j=1:N
            a(i,j)=input(strcat('a(',int2str(i),',',int2str(j),')='));
        end
    end
    disp('Matrix before modification')
    a
    i=1;
    j=1;
    a(i,j)=Max; %Where is Max defined
    Nmax=1,1;
    for i=1       %What range do you expect here?
        for j=1:N
           if a(i,j)>Max  %Where is Max defined
             Max=a(i,j);
             Nmax=i,j;
           end
           if a(Nmax)==Max
              a(i,j)=zeros; %what does zeros do without argumants?   
           end
        end
        k=(j+1)  %what do you think j is at this point N?
        i=(i+1);
    end
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Junior Member
    Joined
    Feb 2008
    Posts
    64
    Quote Originally Posted by CaptainBlack View Post
    Code:
    clear all
    disp('Input size of matrix you would like to create (NxN)')
    N=input('N=');
    for i=1:N
        for j=1:N
            a(i,j)=input(strcat('a(',int2str(i),',',int2str(j),')='));
        end
    end
    disp('Matrix before modification')
    a
    i=1;
    j=1;
    a(i,j)=Max; %Where is Max defined
    Nmax=1,1;
    for i=1       %What range do you expect here?
        for j=1:N
           if a(i,j)>Max  %Where is Max defined
             Max=a(i,j);
             Nmax=i,j;
           end
           if a(Nmax)==Max
              a(i,j)=zeros; %what does zeros do without argumants?   
           end
        end
        k=(j+1)  %what do you think j is at this point N?
        i=(i+1);
    end
    sorry, my code is not very clear, i want to be able to check each column of the matrix and if the biggest number in the column happens to eb on the antidiagonal that particular column will be turned to zeros,
    if im goign to be honest my tutor wrote a bit of the code fro me and im clueless as to what is going on. thanks
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Image/Column space of a Matrix
    Posted in the Advanced Algebra Forum
    Replies: 1
    Last Post: August 14th 2011, 11:24 PM
  2. Replies: 2
    Last Post: February 19th 2011, 06:57 AM
  3. Determine ON-base of the column space of matrix
    Posted in the Advanced Algebra Forum
    Replies: 9
    Last Post: November 4th 2010, 04:52 AM
  4. Full Column rank of a partitioned matrix
    Posted in the Advanced Algebra Forum
    Replies: 1
    Last Post: October 22nd 2009, 11:42 PM
  5. Dimension of the column space of a matrix
    Posted in the Advanced Algebra Forum
    Replies: 2
    Last Post: April 17th 2009, 02:11 AM

Search Tags


/mathhelpforum @mathhelpforum