Interpolating non-independent values

I'm not really sure how to ask this in a concise enough way to find it elsewhere, so I'm just going to ask a new question.
I have two arrays of data, one with time and x values, and one with x and y values. I want to get the y values based on time, but the x values are not uniquely associated with y values.
tx = [0 0;
0.1 1;
0.2 2;
0.3 3;
0.4 2.5;
0.5 2.8;
0.6 2.6];
xy = [0 0;
0.5 0.1;
1 0.15;
1.5 0.2;
2.1 0.22;
2.7 0.3;
3 0.33;
2.6 0.37;
2.5 0.39;
2.7 0.42;
2.8 0.45;
2.6 0.5];
% I can interpolate the axial data to time easily.
x_proper = interp1(tx(:,1),tx(:,2),[0:0.05:0.6]);
% Interpolating with interp1 to get y data limits the y values to <= 0.33,
% because it doesn't understand the bounce in x values.
Here are the assumptions that can be made about the two datasets:
1) tx and xy are applicable over the same total time. Therefore tx([1,end],1) == time of xy([1,end],:)
2) The pattern of x in tx and in xy are matching, and share the same peaks and troughs
3) Due to the time nature of the dataset, each unique (x,y) set will correspond to a unique time

댓글 수: 8

Matt J
Matt J 2021년 3월 29일
Well, clearly t=0.6 maps to both y=0.37 and y=0.5. What rule should be applied to resolve the ambiguity?
Bob Thompson
Bob Thompson 2021년 3월 29일
I think that's part of what I'm trying to figure out, syntaxically.
t = 0.6 does not map to y = 0.37 or y = 0.5 directly, but rather it maps directly to x = 2.6. The problem is that when a curve is drawn along the tx points there are four places where x can equal 2.6, but t = 0.6 and x = 2.6 only happens once, at the very end of the series. Therefore, at t = 0.6, y = 0.5, because that is also the last relationship between x and y. The other 'bounces' are much more difficult to logic.
It is assumed that both data sets cover the same total time, but not necessarily the same time intervals. I suppose I didn't make that clear before, but the xy data is technically time dependent, but the relationship is not directly known, which is why I'm trying to draw the relationships.
Matt J
Matt J 2021년 3월 29일
편집: Matt J 2021년 3월 29일
Is the sampling always equi-spaced in time? t(j+1)-t(j) is a constant independent of j?
It is assumed that both data sets cover the same total time, but not necessarily the same time intervals.
Does this mean t(end)-t(1) is the same in both data sets, but t(1) may vary?
Bob Thompson
Bob Thompson 2021년 3월 29일
It's the opposite of what you're thinking. t(end)- t(1) is constant, and t(1) is constant, but j is not a constant, so the sampling is not constant. I guess that's what I meant by 'interval'.
Matt J
Matt J 2021년 3월 29일
"j is not constant" looks like a typo. Because j is an index ranging over the length of the data set, it is obviously never going to be constant.
Do you mean that t(j+1)-t(j) is not constant over the data set? The sampling is not equi-spaced in time over a fixed data set?
Bob Thompson
Bob Thompson 2021년 3월 29일
Yes.
Matt J
Matt J 2021년 3월 29일
편집: Matt J 2021년 3월 29일
If you had moderately tight upper and lower bounds on the time increments t(j+1)-t(j) then it might be possible to do something. Otherwise, I agree with John that it is a highly ill-posed problem.
Matt J
Matt J 2021년 3월 29일
Here are the assumptions that can be made about the two datasets:
It's basically a 1D image registration problem. The question is, what will be your deformation model...

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

답변 (2개)

John D'Errico
John D'Errico 2021년 3월 29일

1 개 추천

x is non-monotonic as a function of time. I have no idea what you mean by bounce, but I assume it indicates the failure to be monotonic.
You can predict x as a function of time. But now you want to predict y as a function of x? How should MATLAB (or anyone, including me) know how to predict y? x does not vary in any kind of increasing order, so which value of x should be used to predict y? Sorry, but you are asking for something that is not posible.
xy = [0 0;
0.5 0.1;
1 0.15;
1.5 0.2;
2.1 0.22;
2.7 0.3;
3 0.33;
2.6 0.37;
2.5 0.39;
2.7 0.42;
2.8 0.45;
2.6 0.5];
plot(xy(:,1),xy(:,2),'o-')
xline(2.65);
Consider x = 2.65. Which of several (four possible) values of y should be predicted?Can the computer possibly know? Looking at it, I don't even know.

댓글 수: 2

Bob Thompson
Bob Thompson 2021년 3월 29일
Clearly I did not communicate some of the subtext of the problem properly, please see the updated OP.
John D'Errico
John D'Errico 2021년 3월 29일
편집: John D'Errico 2021년 3월 29일
Yes, you did communicate that. What you did not communicate is how you can possibly know from one curve what to do with the second.

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

Matt J
Matt J 2021년 3월 29일
편집: Matt J 2021년 3월 30일

0 개 추천

Assuming you had moderately tight upper and lower bounds U and L on the time increments t(j+1)-t(j) of the xy data set, I can sort of see you attempting an inverse problem to solve for the unknown t(j) as follows.
Fx=griddedInterpolant(tx(:,1), tx(:,2),'spline');
tstart=tx(1,1);
tstop=tx(end,1);
xdata=xy(:,1);
ydata=xy(:,2);
N=numel(xdata)-2;
D=diff(speye(N),1,1); %differencing matrix
Aineq=[D;-D];
bineq=max(0, repelem([U;-L],N-1) );
lb=repelem(tstart,N-1,1);
ub=repelem(tstop,N-1,1);
t0=linspace(tstart,tstop,N+2);
t0([1,end])=[];
t=fmincon(@(t) norm(Fx(t(:))-xdata).^2, t0,Aineq,bineq,[],[],lb,ub,[]);
t=[tstart,t(:).',tstop];
Fy=griddedInterpolant(t,ydata,'spline');

카테고리

도움말 센터File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

제품

릴리스

R2016b

태그

질문:

2021년 3월 29일

편집:

2021년 3월 30일

Community Treasure Hunt

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

Start Hunting!

Translated by