## extracting data around local minima?

### MacKenzie (view profile)

on 18 Nov 2013
Latest activity Edited by MacKenzie

### MacKenzie (view profile)

on 18 Nov 2013

hello,

First, let me give basic framework for the problem: I have data sets that reflect the trajectory of a joystick movement(X,y coordinates in a matrix). The subject needs to move the joystick from neutral past a distance to receive a reward.

I want to extract each pull. One complication is once they reach the target, they stay for a brief moment to collect the reward, just the numbers bounce slightly, giving me many local minima.

I was hoping to have code that reads through the matrix, finds the point where it hits a minimum, stays (perhaps means the noise at the target location), and puts the "pull" into a new matrix or array, etc. There is no consistent number of points between pulls.

I know how to weed out the neutral location data, it's the finding local minima and extracting that is giving me trouble.

Update: I have the local minima. Now, just to get the points in-between each local minima!

thanks!

Image Analyst

### Image Analyst (view profile)

on 18 Nov 2013

Can you attach a data file, and post a diagram or figure or some kind of illustration? Why don't you have vectors? Aren't the x and y both vectors? You could turn it into a 1D vector representing the distance from the starting location.

MacKenzie

### MacKenzie (view profile)

on 18 Nov 2013

yes, good pt; I do have the direction vector, so perhaps using findpeaks on that is a good way to start - let me try and get back to you! thanks for the advice!

MacKenzie

### MacKenzie (view profile)

on 18 Nov 2013

just an update, I found a nice function for detecting local minima (and maxima) where you can set the threshold:

http://www.billauer.co.il/peakdet.html

## Products

### Image Analyst (view profile)

on 18 Nov 2013
```distanceFromFirstPoint = sqrt((x - x(1)) .^ 2 + (y - y(1)) .^ 2);
```

MacKenzie

### MacKenzie (view profile)

on 18 Nov 2013

distanceFromFirstPoint = sqrt((A(:,1) - A(1,1) .^ 2 + (A(:,2)- A(1,2) .^ 2)));

I get imaginary numbers here. something I'm doing wrong to select X vs y?