Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Problem 1132. Create a recurrence matrix for a vector of data

Created by Alex Feinman

In conversation analysis, it's often useful to track the contributions from each speaker to see who talks when. One measurement of engagement between a pair of conversants is to see if they talk to each other more than they talk to other people; for example, at a double date, two old friends might talk to each other more than they talk to their spouses.

Assuming we've coded up the conversation data (e.g. using Gail Jefferson's transcription methods) and assigned a unique number to each participant, MATLAB makes an excellent tool to quickly gather some of these statistics.

Given a vector of speaker observations V, where element V(i) indicates who spoke sentence i in the data, find how many times each element occurs directly after each other element. Note that since we may only be analyzing a part of a larger transcripts, not all speaker numbers may appear in the vector.

Return a matrix containing this data, as well as the list of (ordered) unique elements.

E.g., if V = [1 3 5 3 5 5], then

[R, U] = recurrence(V)
R =
     0     1     0
     0     0     2
     0     1     1
U =
     1     3     5

Such a tool will have other uses, of course.


Problem Group

Solution Statistics

13 correct solutions 6 incorrect solutions
Last solution submitted on Apr 09, 2014