How can I align deterministic signals?

I have some results from a shaking table test that have been carried out.
The input was always the same, however, records where started "by-hand" so they always have different starting times leading to signals that are not aligned. Since I am not an expert in signal processing, I need some help to align them.
I add some example data to this topic to give an idea about the data.

 Respuesta aceptada

Probably the easiest way to do this (with these signals) is simply to threshold the beginning of each to get the index, then use that to adjust the start times for each signal to the same offset.
Try this —
files = dir('*.mat');
for k = 1:numel(files)
LD = load(files(k).name);
fn = fieldnames(LD);
s(k,:) = struct2cell(load(files(k).name, fn{:}));
L(k) = length(s{k});
Fs = 1;
t{k,:} = linspace(0, L(k)-1, L(k))/Fs;
end
figure
hold on
for k = 1:numel(files)
plot(t{k}, s{k})
% ylim([-1 1])
start(k) = find(s{k} > 0.05,1);
end
hold off
grid
[earliest,eidx] = min(start)
earliest = 8221
eidx = 3
figure
tiledlayout(numel(files),1)
for k = 1:numel(files)
nexttile
plot(t{k}, s{k})
grid
xlim([0.75 1.5]*1E+4)
end
sgtitle('Original Signals')
figure
tiledlayout(numel(files),1)
for k = 1:numel(files)
idxrng = start(k) : numel(s{k});
ta{k} = t{k}(1:numel(idxrng)); % Adjusted Time Vector
sa{k} = s{k}(idxrng); % Adjusted Signal Vector
nexttile
plot(ta{k}, sa{k})
grid
end
sgtitle('Time-Adjusted Signals')
.

2 comentarios

alegio20
alegio20 el 16 de Nov. de 2023
Thank you very much!
Star Strider
Star Strider el 16 de Nov. de 2023
As always, my pleasure!

Iniciar sesión para comentar.

Más respuestas (1)

Some of what SS shows might be easier with timetables:
for i = 1:4
signal = load("ew_data"+i+".mat"); signal = signal.ans;
start = find(abs(signal)>0.05,1,'first');
stop = find(abs(signal)>0.05,1,'last');
tt{i} = timetable(signal(start:stop),RowTimes=seconds(1:(stop-start+1))); % dunno what your time units are
end
ttAll = synchronize(tt{:},"union");
ttAll.Properties.VariableNames = "Signal" + (1:4);
stackedplot(ttAll)

6 comentarios

Image Analyst
Image Analyst el 16 de Nov. de 2023
+1 vote for letting us know about synchronize
Peter Perkins
Peter Perkins el 17 de Nov. de 2023
Huh. I think of synchronize as "the value proposition" for timetables. Are you saying you did not know about it? If true, that suggests a documentation shortcoming that we will have to identify.
Star Strider
Star Strider el 17 de Nov. de 2023
I’ve used synchronize and like it. The problem here is that the time vectors weren’t provided (I had to synthesise them in my response), so without even a sampling frequency (that I arbitrarily assumed was the same for all signals), it didn’t seem applicable.
Peter Perkins
Peter Perkins el 17 de Nov. de 2023
Right. I made a lot of assumptions about the time vectors.
alegio20
alegio20 el 17 de Nov. de 2023
@Star Strider your assumption was correct, and the sampling frequency was the same for every signal: 200 Hz.
alegio20
alegio20 el 17 de Nov. de 2023
Thanks for all the great suggestion provided! I will indeed try to use synchronize soon!

Iniciar sesión para comentar.

Categorías

Productos

Versión

R2023b

Preguntada:

el 16 de Nov. de 2023

Comentada:

el 17 de Nov. de 2023

Community Treasure Hunt

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

Start Hunting!

Translated by