Results 1 to 2 of 2

Math Help - Matlab Matrix Compare

  1. #1
    Newbie
    Joined
    Nov 2009
    Posts
    2

    Matlab Matrix Compare

    How would you compare a 1x6 matrix to individual rows of a 10100x6 matrix. I want to know how to compare this 1x6 matrix to each of the rows of the larger matrix one at a time and then count the number of times that they are equivalent.
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Member
    Joined
    Mar 2007
    Posts
    206
    Awards
    1
    Try this:

    Code:
    A = reshape(1:60,6,10)' %matrix containing data
    b = 1:6% row to compare
    c = sum(all(A == repmat(b,size(A,1),1),2))%number of time row occurs
    Results in:
    Code:
    A =
    
         1     2     3     4     5     6
         7     8     9    10    11    12
        13    14    15    16    17    18
        19    20    21    22    23    24
        25    26    27    28    29    30
        31    32    33    34    35    36
        37    38    39    40    41    42
        43    44    45    46    47    48
        49    50    51    52    53    54
        55    56    57    58    59    60
    
    
    b =
    
         1     2     3     4     5     6
    
    
    c =
    
         1
    Regards Elbarto
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. matlab matrix help
    Posted in the Math Software Forum
    Replies: 3
    Last Post: May 18th 2010, 12:21 AM
  2. Matlab matrix in function
    Posted in the Math Software Forum
    Replies: 2
    Last Post: October 14th 2009, 11:24 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. MATLAB: Plotting MATRIX?
    Posted in the Math Software Forum
    Replies: 3
    Last Post: January 25th 2009, 01:21 PM

Search Tags


/mathhelpforum @mathhelpforum