필터 지우기
필터 지우기

Finding data points of two different matrices based off of time

조회 수: 1 (최근 30일)
Krispy Scripts
Krispy Scripts 2016년 10월 25일
댓글: Krispy Scripts 2016년 10월 26일
I have one matrix with data in the first column and time stamps in the second column (datamatrix.mat). The next matrix contains spiketimes (spiketimematrix.mat). I want to get the data point in the first column of first matrix that is the closest time point corresponding to the spike times in spiketimematrix.mat. For example, the first spiketime is 166.1670, which corresponds to the closet time point of 166.1696 and corresponds with the data point 2.5281. I have tried using the following code:
for k=1:length(spiketimesmatrix)
dataout(k)=datamatrix(find(spiketimesmatrix>=datamatrix(:,2),1);
end
I keep getting the first data point as the entire dataoutput.
Not sure if this is clear enough.
  댓글 수: 1
Krispy Scripts
Krispy Scripts 2016년 10월 26일
I am getting the same value repeatedly the size of the spikematrix and I am not sure why.

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

채택된 답변

Chris Dischner
Chris Dischner 2016년 10월 25일
Why not use a difference?
First matrix, a, second matrix b:
for i = 1:length(a)
[m,idx] = min(abs(a(i,2))-b(:,1));
minVal(i) = a(idx,1);
end

추가 답변 (1개)

Walter Roberson
Walter Roberson 2016년 10월 25일
dataout(k)=datamatrix(find(spiketimesmatrix(k)>=datamatrix(:,2),1);
  댓글 수: 2
Krispy Scripts
Krispy Scripts 2016년 10월 26일
My data output is the first value repeated over and over again? I am guessing this is something I am doing incorrectly?
Krispy Scripts
Krispy Scripts 2016년 10월 26일
Actually its not getting the first value, I am not sure what value it is getting, but it is getting it repeatedly over and over again

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

카테고리

Help CenterFile Exchange에서 Workspace Variables and MAT-Files에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by