Shifting one curve to a reference curve using error minimization (fmincon from the Minimization Toolbox)

2 views (last 30 days)
Saeid on 5 Nov 2021
Answered: Saeid on 22 Nov 2021
I need to shift the red curve ONLY horizontally to overlap with the black one. This should be possible using error minimization (e.g. fmincon in the Optimization Toolbox) but I have not managed to do this so far. How can I do this?
Saeid on 5 Nov 2021
The Data are in the excel attachment. [x1 y1] are the reference (black) and [x2 y2] are the data to be shifted horizontally. I want the shifting to be automatic, because in real life there is a large number of such datasets.

Sign in to comment.

Accepted Answer

Mathieu NOE
Mathieu NOE on 5 Nov 2021
hello again
as we look at data plotted in log log scale, a x shift is in fact a multiplicative coefficient on the Y amplitude
see the code and results below
I removed in my computation the first X samples where the two curve are not really parallel so it matches better for x > 10
data = readtable('ShiftData.xlsx');
X1 = data.x1;
Y1 = data.y1;
X2 = data.x2;
Y2 = data.y2;
% avoid taking into account first samples where two curves are not parallel
a = (Y1./Y2);
b = abs(a./rms(a));
ind = find( b> 0.5 & b < 2 );
am = rms(a(ind));
legend('curve 1','curve 2' ,'curve 2 shifted');

Sign in to comment.

More Answers (2)

Community Treasure Hunt

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

Start Hunting!