commit old stuff from lab

This commit is contained in:
Silas Labor Zizou
2025-04-16 09:55:32 +02:00
28 changed files with 728 additions and 60 deletions

View File

@@ -172,9 +172,9 @@ classdef Signal
hold on;
if isempty(options.color)
plot(t, sig(1:length(t)), 'DisplayName', dn, 'LineWidth', 0.1, 'Marker', '.', 'LineStyle','none', 'MarkerSize', 0.1);
plot(t* 1e6, sig(1:length(t)), 'DisplayName', dn, 'LineWidth', 0.1, 'Marker', '.', 'LineStyle','none', 'MarkerSize', 0.1);
else
plot(t, sig(1:length(t)), 'DisplayName', dn, 'LineWidth', 0.1, 'Marker', '.', 'LineStyle','none', 'MarkerSize', 0.1,'Color',options.color);
plot(t* 1e6, sig(1:length(t)), 'DisplayName', dn, 'LineWidth', 0.1, 'Marker', '.', 'LineStyle','none', 'MarkerSize', 0.1,'Color',options.color);
end
% 2 c)
% - xlabel if not already here: time in readable format (1 ms and not 1e-3 s)
@@ -187,10 +187,7 @@ classdef Signal
ylabel('Amplitude');
end
% Convert time axis to milliseconds for readability
xticks = get(gca, 'XTick');
set(gca, 'XTick', xticks, 'XTickLabel', xticks * 1e6);
% Add legend if not already present
if isempty(get(gca, 'Legend'))
legend;
@@ -656,7 +653,7 @@ classdef Signal
end
%%
function [obj,S,isFlipped,sequenceFound] = tsynch(obj,options)
function [obj,S,inverted,sequenceFound,sequenceStarts] = tsynch(obj,options)
% time sync and cut
arguments
obj Signal
@@ -668,9 +665,9 @@ classdef Signal
S = {};
isFlipped=0;
inverted = -1;
sequenceFound = 0;
sequenceStarts = [];
%normalize the signal
@@ -696,8 +693,10 @@ classdef Signal
return
end
if mean(w) > 10 || mean(p) > 10
if mean(w) > 10
warning('No sync possible, check code of findpeaks! Look at correlation')
return
else
sequenceFound = 1;
end
@@ -711,19 +710,19 @@ classdef Signal
shifts = lags(pkpos);
sequenceStarts = shifts;
% shifts = shifts(shifts>=0);
if numel(shifts) > 0
%Cut occurences of ref signal from signal (only positive shifts)
if all(sign(co(pkpos)))
isFlipped = 1;
if all(sign(co(pkpos))==-1)
inverted = 1;
end
for c = shifts
sig = obj.delay(-c,'mode','samples');
sig.signal = sig.signal(1:length(b)).*-isFlipped;
sig.signal = sig.signal(1:length(b)) .* -inverted;
S{end+1,1} = sig;
end