Count number of matrix elements in a given vector

Background: Need to count the number of correct elements in a series of ranked lists.
I have a matrix where with j columns and 30 rows. Each column has the numbers 1:30 in random order. I have a vector "actual" with the numbers 1:30 in the correct order.
For each of the columns, how do I count the number of each columns elements that are in the correct place?

 Respuesta aceptada

James Tursa
James Tursa el 6 de Feb. de 2015
M = 30 x j matrix of random ordered numbers 1:30
C = 30 x 1 "correct" ordering of 1:30
N = sum(bsxfun(@eq,M,C)); % Number of correct element spots in each column

Más respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.

Preguntada:

el 6 de Feb. de 2015

Comentada:

el 7 de Feb. de 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by