chnages from silas pc again

This commit is contained in:
Silas Oettinghaus
2025-04-16 09:51:15 +02:00
parent 2fcd6854ea
commit 651be1ff54
9 changed files with 367 additions and 25 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
@@ -711,19 +708,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