How to plot data with different acquisition rates versus each other

I acquired one set of data at 170 Hz and a different set of data at 700 Hz. This leads to differing lengths of data sets, but I need to plot the two sets of data against each other, one set on the x-axis, the other on the y-axis. My example is that I have a tool penetrating a surface and data is being collected on the penetration depth at 170 Hz. Then a reactionary force is collected at 700 Hz as the tool penetrates the surface. I need to plot the reactionary force versus the penetration depth in order to calculate compaction density of the sample. I cannot change the sample rates. Can anyone help me to plot this kind of data?

 Accepted Answer

The only way to equalise them would be to use interp1 to interpolate the longer vector in terms of the shorter vector. It has the effect of downsampling the longer vector.
For example:
t1 = linspace(0, 1, 170); % Create Data
t2 = linspace(0, 1, 700);
s1 = sin(t1*2*pi);
s2 = cos(t2*2*pi);
figure(1)
plot(t1, s1, '.', t2, s2, 'o')
grid
s2i = interp1(t2, s2, t1, 'linear', 'extrap'); % Interpolate
figure(2)
plot(t1, s1, '.', t1, s2i, 'o')
grid
figure(3)
plot(s1, s2i, '.')
grid

More Answers (1)

Thank you very much! This allowed me to plot my data and the expected trend for depth versus force is shown in my plot!

Categories

Products

Community Treasure Hunt

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

Start Hunting!