2
$\begingroup$

I have the following data plots for the voltage curve vs time. I want to shift the plots on the x axis such that the peaks and troughs coincide. Any ideas as to how to go about doing this will be appreciatedVoltage vs time plot for falling magnet through a coil

$\endgroup$
2

1 Answer 1

2
$\begingroup$

I don't have your data so I'll generate my own:

datax = Table[i/100, {i, 1, 100}];
data1 = Table[Exp[-(i - 50 + 10)^2/20^2] + .1 RandomReal[], {i, 1, 100}];
data2 = Table[Exp[-(i - 50 + 0)^2/20^2] + .1 RandomReal[], {i, 1, 100}];
data3 = Table[Exp[-(i - 50 - 20)^2/20^2] + .1 RandomReal[], {i, 1, 100}];

Show[
 ListPlot[Transpose[{datax, data1}], PlotStyle -> Blue],
 ListPlot[Transpose[{datax, data2}], PlotStyle -> Red],
 ListPlot[Transpose[{datax, data3}], PlotStyle -> Green]
]

enter image description here

In order to shift the data so that the maxima coincide, we can use

Show[
 ListPlot[Transpose[{datax - datax[[Position[data1, Max[data1]][[1, 1]]]], data1}], PlotStyle -> Blue],
 ListPlot[Transpose[{datax - datax[[Position[data2, Max[data2]][[1, 1]]]], data2}], PlotStyle -> Red],
 ListPlot[Transpose[{datax - datax[[Position[data3, Max[data3]][[1, 1]]]], data3}], PlotStyle -> Green]
]

enter image description here

$\endgroup$
1
  • $\begingroup$ It did work. Only I had to replace ListPlot with ListLinePlot. I would be grateful if you could explain what you did here $\endgroup$ Mar 21, 2017 at 17:40

Not the answer you're looking for? Browse other questions tagged or ask your own question.