Home > database >  How to shift signal by fractional step in Matlab?
How to shift signal by fractional step in Matlab?

Time:02-24

I have two signals from an oscilloscope. Each of them has 1000 points with a 1ns step. I need to see the difference between signals. But the signals are shifted by 0.31ns. I can create two plots with aligned signals with the command

plot(time, signal1, time 0.31, signal2);

But how can I plot the difference of de-shifted (aligned) signals?

CodePudding user response:

Use the interp1 function:

vq = interp1(x,v,xq)
vq = interp1(x,v,xq,method)
vq = interp1(x,v,xq,method,extrapolation)

vq = interp1(x,v,xq) returns interpolated values of a 1-D function at specific query points using linear interpolation. Vector x contains the sample points, and v contains the corresponding values, v(x). Vector xq contains the coordinates of the query points.

For your example try something like:

signal2_prime = interp1(time 0.31, signal2, time);
plot(time, signal1, time, signal2_prime)
  • Related