Results 1 to 4 of 4

Math Help - matlab matrix help

  1. #1
    Newbie
    Joined
    May 2010
    Posts
    2

    matlab matrix help

    hello,

    using MATLAB

    I currently have a matrix of the form:

    [54 4 2 6 45;
    .1 .2 .3 .4 .5]

    I am trying to find a way to extract the column that contains the minimum row one value.

    ie, for this case to extract 2 & 3

    row one is minimum receptances
    row two is the corresponding spring constants

    so really all i actually need is to be able to extract the spring value from row 2 that corresponds to the minimum value in row 1


    any help would me much appreciated
    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 metcat01 View Post
    hello,

    using MATLAB

    I currently have a matrix of the form:

    [54 4 2 6 45;
    .1 .2 .3 .4 .5]

    I am trying to find a way to extract the column that contains the minimum row one value.

    ie, for this case to extract 2 & 3

    row one is minimum receptances
    row two is the corresponding spring constants

    so really all i actually need is to be able to extract the spring value from row 2 that corresponds to the minimum value in row 1


    any help would me much appreciated
    Code:
    A=[54 4 2 6 45;
        .1 .2 .3 .4 .5];
     
    [r1,id]=sort(A(1,:));
     
    B=A(:,id(1))
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Member
    Joined
    Mar 2007
    Posts
    206
    Awards
    1
    If there is only one minimum value in the first row you could do it as follows also:

    Code:
    B = A(:,find(A(1,:)==min(A(1,:))))%provided there is only 1 minimum
    Regards Elbarto
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Newbie
    Joined
    May 2010
    Posts
    2
    Thanks heaps guys.

    that first solution was exactly what we were after.

    just handed the assignment in and am very happy with it so cheers for taking the time to help us out.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Matlab - Storing a row for a matrix?
    Posted in the Math Software Forum
    Replies: 6
    Last Post: March 30th 2010, 03:16 AM
  2. Matrix Operations in MATLAB
    Posted in the Math Software Forum
    Replies: 0
    Last Post: February 9th 2010, 09:31 PM
  3. Matlab ( Matrix )
    Posted in the Math Software Forum
    Replies: 2
    Last Post: April 6th 2009, 01:32 AM
  4. Matlab help ........Matrix
    Posted in the Math Software Forum
    Replies: 0
    Last Post: April 4th 2009, 06:05 AM
  5. matrix size in matlab
    Posted in the Math Software Forum
    Replies: 4
    Last Post: November 23rd 2008, 02:38 AM

Search Tags


/mathhelpforum @mathhelpforum