Commit 4165bf91 authored by Lennart Heeren's avatar Lennart Heeren
Browse files

Gitlab Runner Update from grt-auxfiles/master:Merge branch '119-4.10-delta' into 'master'

parent 7d327ad9
function [] = Problem4_10_PlotSinusComparison(data,input, frequency)
function [] = Problem4_10_PlotSinusComparison(output,input, frequency)
% plotSinusComparison(data,input, frequency)
%
......@@ -19,13 +19,13 @@ function [] = Problem4_10_PlotSinusComparison(data,input, frequency)
%%
close all
%%
diff1 = diff(data.signals.values(:,1));
diff1 = diff(output.signals.values(:,1));
if any(abs(diff1(:))>10)
in_delete = find(abs(diff1(:))>10);
input.signals.values(in_delete,:)=[];
data.signals.values(in_delete,:)=[];
output.signals.values(in_delete,:)=[];
input.time(in_delete,:)=[];
data.time(in_delete,:)=[];
output.time(in_delete,:)=[];
end
start_val = find(input.time/(2*pi)>1,1,'first');
......@@ -39,17 +39,17 @@ max_in = max(input.signals.values(ind_max_first:end,1));
min_in = min(input.signals.values(ind_max_first:end,1));
mean_in = min_in/2+max_in/2;
max_data = max(data.signals.values(ind_max_first:end,1));
min_data = min(data.signals.values(ind_max_first:end,1));
max_data = max(output.signals.values(ind_max_first:end,1));
min_data = min(output.signals.values(ind_max_first:end,1));
mean_data = min_data/2+max_data/2;
if frequency>=1
mean_data = mean(data.signals.values(ind_max_first:end,1));
a=sign(diff(data.signals.values(ind_max_first:end,1)));
mean_data = mean(output.signals.values(ind_max_first:end,1));
a=sign(diff(output.signals.values(ind_max_first:end,1)));
cross_pos = find(diff(a)==-2)+ind_max_first-1;
cross_neg = find(diff(a)==2)+ind_max_first-1;
data_cross_pos = data.signals.values(cross_pos+1,1);
data_cross_neg = data.signals.values(cross_neg+1,1);
data_cross_pos = output.signals.values(cross_pos+1,1);
data_cross_neg = output.signals.values(cross_neg+1,1);
max_data = mean(data_cross_pos(data_cross_pos>mean_data));
min_data = mean(data_cross_neg(data_cross_neg<mean_data));
end
......@@ -59,7 +59,7 @@ set(gcf, 'Position', [200, 50 1000 600])
subplot(1,2,1)
hold on
box on
plot((data.time(ind_max_first:end)-data.time(ind_max_first))/(2*pi), data.signals.values(ind_max_first:end,1)-mean_data, 'b');
plot((output.time(ind_max_first:end)-output.time(ind_max_first))/(2*pi), output.signals.values(ind_max_first:end,1)-mean_data, 'b');
plot((input.time(ind_max_first:end)-input.time(ind_max_first))/(2*pi), (input.signals.values(ind_max_first:end,1)-mean_in), 'r');
plot([0 (input.time(end)-input.time(ind_max_first))/(2*pi)], (max_in-min_in)/2*[ampl ampl], 'g--', 'Linewidth', 2)
......@@ -73,13 +73,13 @@ subplot(1,2,2)
hold on
box on
title('Phase detection')
if data.time(end)/(2*pi)>1.75/frequency
x_data_t = (data.time(ind_max_first:end)-data.time(ind_max_first))/(2*pi);
if output.time(end)/(2*pi)>1.75/frequency
x_data_t = (output.time(ind_max_first:end)-output.time(ind_max_first))/(2*pi);
x_data = x_data_t(find(x_data_t>=0.75/frequency,1, 'first'):find(x_data_t>=1.75/frequency, 1, 'first'));
x_data = (x_data-x_data(1))*frequency*360;
y_data_in = ampl*(input.signals.values(ind_max_first:end,1)-mean_in);
y_data_in = y_data_in(find(x_data_t>=0.75/frequency,1, 'first'):find(x_data_t>=1.75/frequency,1, 'first'));
y_data_data = data.signals.values(ind_max_first:end,1)-mean_data;
y_data_data = output.signals.values(ind_max_first:end,1)-mean_data;
y_data_data = y_data_data(find(x_data_t>=0.75/frequency,1, 'first'):find(x_data_t>=1.75/frequency,1, 'first'));
plot(x_data, y_data_data, 'b');
plot(x_data, y_data_in, 'r');
......@@ -96,13 +96,13 @@ if data.time(end)/(2*pi)>1.75/frequency
plot([0, -phase_angle],[0,0],'g--', 'Linewidth', 2)
else
if data.time(end)/(2*pi)>1.25/frequency
x_data_t = (data.time(ind_max_first:end)-data.time(ind_max_first))/(2*pi);
if output.time(end)/(2*pi)>1.25/frequency
x_data_t = (output.time(ind_max_first:end)-output.time(ind_max_first))/(2*pi);
x_data = x_data_t(find(x_data_t>=0.25/frequency,1, 'first'):find(x_data_t>=1.25/frequency, 1, 'first'));
x_data = (x_data-x_data(1))*frequency*360;
y_data_in = ampl*(input.signals.values(ind_max_first:end,1)-mean_in);
y_data_in = y_data_in(find(x_data_t>=0.25/frequency,1, 'first'):find(x_data_t>=1.25/frequency,1, 'first'));
y_data_data = data.signals.values(ind_max_first:end,1)-mean_data;
y_data_data = output.signals.values(ind_max_first:end,1)-mean_data;
y_data_data = y_data_data(find(x_data_t>=0.25/frequency,1, 'first'):find(x_data_t>=1.25/frequency,1, 'first'));
plot(x_data, y_data_data, 'b');
plot(x_data, y_data_in, 'r');
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment