필터 지우기
필터 지우기

Calculating displacement many times with respect to different elements

조회 수: 2 (최근 30일)
Timothy Russell
Timothy Russell 2013년 1월 28일
I have the following data (or similar):
154240 1 7
154240 2 2
154240 5 6
154240 2 5
154240 6 7
154240 2 7
154240 5 6
154240 6 7
154240 4 6
154240 4 6
154240 4 6
641224 2 3
641224 2 1
641224 2 3
641224 1 2
641311 5 5
641311 7 5
It represents data of the form [tag number of rat, x coord, y coord] (as im studying a rat population). I would like to calculate the displacement of x & y with respect to the first x & y entries for each of the same value of the tag, i.e. I want an nx3 matrix (where n is size of my data) which gives me [tag number again,(0,x2-x1,x3-x1,x4-x1 etc),(0,y2-y1,y3-y1,y4-y1 etc)] but I am totally inept at programming and am flummoxed right now.
Any help is greatly appreciated!
  댓글 수: 1
Sean de Wolski
Sean de Wolski 2013년 1월 28일
So what output do you expect for you above input? Please describe to us how you get that. Results are worth a 1000 words!

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

답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2013년 1월 28일
X your array
out=bsxfun(@minus,X,[0 X(1,2) X(1,3)])
  댓글 수: 1
Timothy Russell
Timothy Russell 2013년 1월 29일
This is great, but I the first x & y displacement for each different tag number needs to be (0,0) (as the displacement for the first time a rat is captured is (0,0)), and this isn't doing that. Is there an easy way to split up a matrix into seperate matricies by using the element in the first column (i.e. the tag number in this case)? Thanks though, it does what I wanted, I just haven't sort my data out properly yet!

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

카테고리

Help CenterFile Exchange에서 Data Import and Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by