Players distribution in soccer field
3 views (last 30 days)
Show older comments
Sérgio Querido
on 16 Apr 2015
Commented: Image Analyst
on 19 Apr 2015
Hello,
I have the coordinates (x,y) of a lot of soccer players and i want to know their field distribution. I want to part the field (120m x 90m) in 1m2 bens. With this, i want to now how many times, players are in each bens.
Can you help me please with the best code to run this in matlab?
SQ
0 Comments
Accepted Answer
Image Analyst
on 17 Apr 2015
You need a 2D histogram, like http://www.mathworks.com/matlabcentral/fileexchange/12346-hist2-for-the-people?s_cid=srchtitle
If you have the Statistics and Machine Learning Toolbox you can use hist3: http://www.mathworks.com/help/stats/hist3.html?s_cid=srchtitle which looks just like what you want and need.
2 Comments
Image Analyst
on 19 Apr 2015
If xy is your N by 2 matrix of x and y locations for the players (each player is one row), then, if you have the Statistics and Machine Learning Toolbox, do this:
hist3(xy,[120, 90])

clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 20;
numberOfPeopleOnField = 1000;
% Make up some X coordinates for numberOfPeopleOnField people.
x = 120 * rand(numberOfPeopleOnField, 1);
% Make up some Y coordinates for numberOfPeopleOnField people.
y = 90 * rand(numberOfPeopleOnField, 1);
xy = [x, y];
hist3(xy,[120, 90])
xlabel('X', 'FontSize', fontSize);
ylabel('Y', 'FontSize', fontSize);
zlabel('Count (# of People)', 'FontSize', fontSize);
You'll note that most 1 square meter regions have only 0 or 1 plyaer in them. I had to put a lot of players on the field to get more than 2 playes in a 1 square meter square.
More Answers (1)
See Also
Categories
Find more on Histograms in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!