Players distribution in soccer field
5 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Image Analyst
2015-4-17
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 个评论
Image Analyst
2015-4-19
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.
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Descriptive Statistics and Visualization 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!