67 lines
2.1 KiB
Matlab
67 lines
2.1 KiB
Matlab
% Liste der Strukturen definieren
|
|
structs = {S0, S2, S4, S6, S8, S10};
|
|
|
|
% Entitäten mit 2ms Samplingrate (dt = 0.002 s)
|
|
entities_2ms = {'ACTPOS', 'SETPOS', 'ACTVELO', 'POSDIFF', 'ActTorque'};
|
|
dt_2ms = 0.002;
|
|
dt_10ms = 0.010;
|
|
|
|
for s = 1:length(structs)
|
|
S = structs{s};
|
|
|
|
% 1. Filtermaske auf Basis von ACTVELO erstellen
|
|
% Behielt Werte außerhalb des Intervalls [-0.005, 0.005]
|
|
keep_mask_2ms = abs(S.ACTVELO.y) > 0.25;
|
|
|
|
% 2. 2ms-Entitäten filtern und Zeitvektoren neu aufbauen
|
|
for e = 1:length(entities_2ms)
|
|
ent = entities_2ms{e};
|
|
if isfield(S, ent)
|
|
% Y-Daten filtern
|
|
y_sync = S.(ent).y(keep_mask_2ms);
|
|
|
|
% Neuen Zeitvektor erzeugen (startend bei 0 s)
|
|
N = length(y_sync);
|
|
t_sync = (0:N-1)' * dt_2ms;
|
|
|
|
% Vektorausrichtung (Zeile/Spalte) der Quelldaten beibehalten
|
|
if isrow(S.(ent).y)
|
|
y_sync = y_sync';
|
|
t_sync = t_sync';
|
|
end
|
|
|
|
S.(ent).y = y_sync;
|
|
S.(ent).t = t_sync;
|
|
end
|
|
end
|
|
|
|
% 3. current_mA (10ms-Raster, Abstand 1:5) filtern und Zeitvektor neu aufbauen
|
|
if isfield(S, 'current_mA')
|
|
% Maske auf das 10ms-Raster übertragen (jeden 5. Abtastwert)
|
|
keep_mask_10ms = keep_mask_2ms(1:5:end);
|
|
|
|
% Längenabgleich zur Sicherheit
|
|
N_curr_orig = length(S.current_mA.y);
|
|
keep_mask_10ms = keep_mask_10ms(1:min(length(keep_mask_10ms), N_curr_orig));
|
|
|
|
y_curr_sync = S.current_mA.y(keep_mask_10ms);
|
|
|
|
% Neuer 10ms-Zeitvektor
|
|
N_curr = length(y_curr_sync);
|
|
t_curr_sync = (0:N_curr-1)' * dt_10ms;
|
|
|
|
if isrow(S.current_mA.y)
|
|
y_curr_sync = y_curr_sync';
|
|
t_curr_sync = t_curr_sync';
|
|
end
|
|
|
|
S.current_mA.y = y_curr_sync;
|
|
S.current_mA.t = t_curr_sync;
|
|
end
|
|
|
|
structs{s} = S;
|
|
end
|
|
|
|
% Verarbeitete Strukturen zurück in die Workspace-Variablen schreiben
|
|
S0 = structs{1}; S2 = structs{2}; S4 = structs{3};
|
|
S6 = structs{4}; S8 = structs{5}; S10 = structs{6}; |