Create a recurrence matrix for a vector of data - MATLAB Cody - MATLAB Central

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

Difficulty:Rate

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.

Solution Stats

72.97% Correct | 27.03% Incorrect
Last Solution submitted on Feb 07, 2023

Problem Comments

Solution Comments

Show comments
R2025a Pre-release highlights
This topic is for discussing highlights to the current R2025a Pre-release.
13
5

Problem Recent Solvers21

Suggested Problems

More from this Author3

Problem Tags

Community Treasure Hunt

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

Start Hunting!
Go to top of page