The sequence of actions in a vector (football match)

조회 수: 1 (최근 30일)
Aragorn23
Aragorn23 2019년 6월 28일
댓글: Aragorn23 2019년 7월 2일
Hi everyone,
I am a Sports Science student, and I am starting to use Matlab.
I analysed a football match, and in an excel' column I put the sequence of actions that a team made:
"Player1
Player2
Player 11
Player1
shoot"
"Player1
Player2
Player 11
Player1
missed pass"
In the example, I represented two ball possessions, the first ends with a "shoot" and the second one end with a "missed pass". According to the example, I would like to represent the number of ball possessions of that team in another column:
1
1
1
1
1
2
2
2
2
2
How can I do that?
P.S. When two players appear in a row, there was a pass between them. Furthermore, I already changed the name of the players per numbers, as well as the technical actions (shoot, missed pass, etc...).
Regards,
  댓글 수: 6
Guillaume
Guillaume 2019년 6월 30일
So, you've got a column vector of numbers?
And the change of possession is whenever there's any number >= 50?
Aragorn23
Aragorn23 2019년 6월 30일
Exactly.

댓글을 달려면 로그인하십시오.

채택된 답변

Guillaume
Guillaume 2019년 6월 30일
No idea how we went from your original question to a vector of numbers. Anyway, if I understood correctly:
%example data
match = [9; 10; 6; 7; 8; 11; 10; 51; 4; 5; 11; 9; 50; 8; 4; 10; 53; 1; 2; 6; 7; 10; 9; 11; 54]
%not entirely clear on the desired output
%either
possession1 = cumsum([1; match(1:end-1)>=50])
%or
possession2 = mod(cumsum([0; match(1:end-1)>=50]), 2) + 1
%for visualisation of the results:
table(match, possession1, possession2)
  댓글 수: 3
Guillaume
Guillaume 2019년 7월 2일
It's even simpler:
possession = cumsum(match >= 50) + 1
Aragorn23
Aragorn23 2019년 7월 2일
It worked. Thank you again

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by