필터 지우기
필터 지우기

How do I select specific data from a matrix with a loop?

조회 수: 3 (최근 30일)
jakobjakob
jakobjakob 2018년 6월 6일
답변: Stephen23 2018년 6월 6일
I have done research on viewing behavior in football matches. I want to create a graph with the frequency on the y-axis and on the x-axis the viewing behavior over the 10 before the first touch of the ball. From the matrix (see image) I must therefore first encode when there is a first ball contact, then at the corresponding time I have to view the viewing behavior in the previous 10 seconds. Selecting he first touch of the ball succeeded, but not 'code' the interval of 10 seconds before the first touch. Who could help me?
  댓글 수: 2
Stephen23
Stephen23 2018년 6월 6일
편집: Stephen23 2018년 6월 6일
@jakobjakob: please upload the code you have been writing by clicking the paperclip button.
jakobjakob
jakobjakob 2018년 6월 6일
The problem is that i don't have a code about this specific part. Maybe you have some tips to select a interval in a matrix?

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

답변 (1개)

Stephen23
Stephen23 2018년 6월 6일
Fundamentally it will come down to indexing into your data matrix C (which seems to be a cell array: is this correct?). Here is an outline:
  • convert the time column to a numeric vector, e.g. TV = [C{:,1}];.
  • loop through each "touch" value...
  • get the index of the "touch" row, e.g. idx.
  • use idx to get the time of that row: TT = TV(idx).
  • compare all times in to find the ones that you want, e.g. idt = TV>=TT-10 & TV<=TT.
  • you can then analyze those rows: C(idt,:).

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by