Shif factors in X and y directions

4 views (last 30 days)
Raj Raj
Raj Raj on 29 Sep 2014
Commented: Raj Raj on 1 Oct 2014
Hi all, I have to find the x and y shift factor of the curves. I started as follows however coudnt know how to proceed further. Here is the code objective. Let me have two data sets {t1, E1} and {t2, E2} and so on. Lets consider only two data sets for time being.
where
E1'
ans =
-1.6817 -1.6806 -1.6796 -1.6788 -1.6775 -1.6766 -1.6758 -1.6751 -1.6748 -1.6737 -1.6731
>> t1'
ans =
-0.7782 -0.9823 -1.1761 -1.3802 -1.5775 -1.7782 -1.9823 -2.1761 -2.2553 -2.5775 -2.7782
>> E2'
ans =
-1.6820 -1.6811 -1.6803 -1.6795 -1.6785 -1.6777 -1.6769 -1.6762 -1.6759 -1.6749 -1.6742
>> t2'
ans =
-0.7782 -0.9823 -1.1761 -1.3802 -1.5775 -1.7782 -1.9823 -2.1761 -2.2553 -2.5775 -2.7782
polynomials were fitted as
p1 =polyfit(t1, E1 , 2); p2 =polyfit(t2, E2 , 2)
I plotted the data as follows for graphical visualization:
plot(t1,E1,'o', t2,E2,'+')
hold on
plot(t1, polyval(p1, t1), t2, polyval(p2, t2) )
Aim is to shift the E2-t2 data in x and y directions to minimize the error such that I can find the shifts in x and y directions. (I have found a similar procedure in this paper, Figure 4: http://www.eng.uc.edu/~beaucag/Classes/Characterization/DMA%20Lab/IF1.1%20Fukushima.pdf)
Please let me know suitable commands to do this. Appreciate your time. Thanks!
  3 Comments
SK
SK on 30 Sep 2014
What is your meaning of "error". Is it sum of squares of differences in the y values?
I notice that t1 and t2 have the same starting and ending point. So if we use the above definition, no x-shift can be done, only y shift.
Also do you want to just shift or rescale each graph non-linearly along the x-axis? Need more details.

Sign in to comment.

Answers (2)

Stephen23
Stephen23 on 30 Sep 2014
Edited: Stephen23 on 30 Sep 2014
Sounds like homework.
Assuming that the curves are not rotated, repeated, mirrored, dilated, nor sheared, and match for some unique combination of x and y offsets, then this should be do-able.
Some hints:
  • define functions that calculate the residual distance between two vectors, with x and y shift factors as variables.
  • create vectors for both the x and y shift, containing the range that you would like to consider.
  • apply the functions to each combination of x and y offsets...
  • find the minimum.
You could also use an optimization function , such as fminbnd.

Raj Raj
Raj Raj on 1 Oct 2014
Edited: Raj Raj on 1 Oct 2014
Hi Stephen and SK,
First of all thanks for your attention.
Actually its not a homework. Its a program to process my experimental data. Though its not a major part of my work, I just stuck up at this stage for more than a week. Here is my approach.
y2sampledInx1 = @(c) interp1(c(1)+x2,y2,x1,'cubic', 'extrap');
err = @(c) sum((c(2)+y2sampledInx1(c)-y1).^2);
x0=[10; 10];
%Here I tried three solvers. But all the three solutions are depending highly on the initial guess values i.e. x0. This is the big issue. a
coeffs = fminunc(err,x0)
coeffs = lsqnonlin(err,x0)
coeffs = fminsearch(err,x0)
Hope to hear your inputs. Thanks!
p.s. Is there any way to avoid the sensitivity of the x0 on the final solution.
  1 Comment
Raj Raj
Raj Raj on 1 Oct 2014
Able to solve the global minimum using
gs = GlobalSearch;
[coeffs,f] = run(gs,problem)
Cheers to all

Sign in to comment.

Products

Community Treasure Hunt

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

Start Hunting!