Results 1 to 2 of 2

Math Help - Matlab help wwith matrices

  1. #1
    Newbie
    Joined
    Jul 2010
    Posts
    1

    Matlab help wwith matrices

    Hello all,
    I am working on Matlab and need some help. How can I search for a single element from a nx2 matrix? for example:

    if A = 12 0
    15 1
    17 0
    19 0
    20 1
    then how can I find out whether the value of '20' is '1' or '0' ?
    I'm just using this as a flag and cant seem to figure it out. Is there any other way to do this?

    Thank you.
    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 neosam View Post
    Hello all,
    I am working on Matlab and need some help. How can I search for a single element from a nx2 matrix? for example:

    if A = 12 0
    15 1
    17 0
    19 0
    20 1
    then how can I find out whether the value of '20' is '1' or '0' ?
    I'm just using this as a flag and cant seem to figure it out. Is there any other way to do this?

    Thank you.
    Code:
    >a20=A(find(A(:,1)==20),2);
    Note if there is no "20" in the first column you should end up with an empty matrix

    CB
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Replies: 12
    Last Post: December 2nd 2011, 01:02 PM
  2. Replies: 1
    Last Post: August 29th 2011, 07:49 PM
  3. How to program this in matlab or python: matrices
    Posted in the Math Software Forum
    Replies: 0
    Last Post: April 19th 2011, 09:02 AM
  4. Matlab function and matrices help
    Posted in the Math Software Forum
    Replies: 2
    Last Post: May 18th 2010, 02:54 PM
  5. matlab matrices code - urgent
    Posted in the Math Software Forum
    Replies: 0
    Last Post: November 22nd 2009, 10:00 AM

Search Tags


/mathhelpforum @mathhelpforum