Interpolating non-independent values
조회 수: 1(최근 30일)
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;
xy = [0 0;
% 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
John D'Errico 2021년 3월 29일
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;
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.
Matt J 2021년 3월 29일
편집: Matt J 2021년 3월 30일
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.
D=diff(speye(N),1,1); %differencing matrix
bineq=max(0, repelem([U;-L],N-1) );
t=fmincon(@(t) norm(Fx(t(:))-xdata).^2, t0,Aineq,bineq,,,lb,ub,);