%тестовые сигналы
clc;
clear all;
close all;
X0=50;
Y0=80;
W0=1200;
H0=600;
x1=50;
y1=430;
w1=200;
h1=150;
dy=30;
dx=20;
w2=40;
h2=10;
figure('Color','[1 1 1]','Position',[X0,Y0,W0,H0]);
hAxes11=axes('Units','pixels','Position',[x1,y1,w1,h1]);
hAxes21=axes('Units','pixels','Position',[x1,y1-h1-dy,w1,h1]);
hAxes31=axes('Units','pixels','Position',[x1,y1-2*h1-2*dy,w1,h1]);
hAxes12=axes('Units','pixels','Position',[x1+w1+dx,y1,2*w1,h1]);
hAxes22=axes('Units','pixels','Position',[x1+w1+dx,y1-h1-dy,2*w1,h1]);
hAxes32=axes('Units','pixels','Position',[x1+w1+dx,y1-2*h1-2*dy,2*w1,h1]);
hAxes13=axes('Units','pixels','Position',[x1+3*w1+2*dx,y1,2*w1,h1]);
hAxes23=axes('Units','pixels','Position',[x1+3*w1+2*dx,y1-h1-dy,2*w1,h1]);
hAxes33=axes('Units','pixels','Position',[x1+3*w1+2*dx,y1-2*h1-2*dy,2*w1,h1]);
%параметры сигнала
A1=25;
A2=10;
F1=9;
F2=5;
Fs=350;
tmax=0.8;
T=1/Fs;
t=0:T:tmax-T;
S1=A1*sin(2*pi*F1*t);
S2=A2*sin(2*pi*F2*t);
S3=S1+S2;
axes(hAxes11);
plot(t,S1);
grid minor;
axes(hAxes21);
plot(t,S2);
grid minor;
axes(hAxes31);
plot(t,S3);
grid minor;
%OY
Asum=A1+A2;
set(hAxes11,'Ylim',[-Asum Asum]);
hold on;
set(hAxes21,'Ylim',[-Asum Asum]);
hold on;
set(hAxes31,'Ylim',[-Asum Asum]);
hold on;
%АКФ
tcf=-tmax+T:T:tmax-T;
acf1=xcorr(S1,'coeff');
axes(hAxes12);
set(hAxes12,'Ylim',[-1 1]);
hold on;
plot(tcf,acf1);
grid minor;
acf2=xcorr(S2,'coeff');
axes(hAxes22);
set(hAxes22,'Ylim',[-1 1]);
hold on;
plot(tcf,acf2);
grid minor;
acf3=xcorr(S3,'coeff');
axes(hAxes32);
set(hAxes32,'Ylim',[-1 1]);
hold on;
plot(tcf,acf3);
grid minor;
%ВКФ
ccf13=xcorr(S1,S3,'coeff');
axes(hAxes13);
ylim([-1 1]);
hold on;
plot(tcf,ccf13);
grid minor;
ccf23=xcorr(S2,S3,'coeff');
axes(hAxes23);
ylim([-1 1]);
hold on;
plot(tcf,ccf23);
grid minor;
ccf31=xcorr(S3,S1,'coeff');
axes(hAxes33);
ylim([-1 1]);
hold on;
plot(tcf,ccf31);
grid minor;
clc;
clear all;
close all;
X0=50;
Y0=80;
W0=1200;
H0=600;
x1=50;
y1=430;
w1=200;
h1=150;
dy=30;
dx=20;
w2=40;
h2=10;
figure('Color','[1 1 1]','Position',[X0,Y0,W0,H0]);
hAxes11=axes('Units','pixels','Position',[x1,y1,w1,h1]);
hAxes21=axes('Units','pixels','Position',[x1,y1-h1-dy,w1,h1]);
hAxes31=axes('Units','pixels','Position',[x1,y1-2*h1-2*dy,w1,h1]);
hAxes12=axes('Units','pixels','Position',[x1+w1+dx,y1,2*w1,h1]);
hAxes22=axes('Units','pixels','Position',[x1+w1+dx,y1-h1-dy,2*w1,h1]);
hAxes32=axes('Units','pixels','Position',[x1+w1+dx,y1-2*h1-2*dy,2*w1,h1]);
hAxes13=axes('Units','pixels','Position',[x1+3*w1+2*dx,y1,2*w1,h1]);
hAxes23=axes('Units','pixels','Position',[x1+3*w1+2*dx,y1-h1-dy,2*w1,h1]);
hAxes33=axes('Units','pixels','Position',[x1+3*w1+2*dx,y1-2*h1-2*dy,2*w1,h1]);
%параметры сигнала
A1=25;
A2=10;
F1=9;
F2=5;
Fs=350;
tmax=0.8;
T=1/Fs;
t=0:T:tmax-T;
S1=A1*sin(2*pi*F1*t);
S2=A2*sin(2*pi*F2*t);
S3=S1+S2;
axes(hAxes11);
plot(t,S1);
grid minor;
axes(hAxes21);
plot(t,S2);
grid minor;
axes(hAxes31);
plot(t,S3);
grid minor;
%OY
Asum=A1+A2;
set(hAxes11,'Ylim',[-Asum Asum]);
hold on;
set(hAxes21,'Ylim',[-Asum Asum]);
hold on;
set(hAxes31,'Ylim',[-Asum Asum]);
hold on;
%АКФ
tcf=-tmax+T:T:tmax-T;
acf1=xcorr(S1,'coeff');
axes(hAxes12);
set(hAxes12,'Ylim',[-1 1]);
hold on;
plot(tcf,acf1);
grid minor;
acf2=xcorr(S2,'coeff');
axes(hAxes22);
set(hAxes22,'Ylim',[-1 1]);
hold on;
plot(tcf,acf2);
grid minor;
acf3=xcorr(S3,'coeff');
axes(hAxes32);
set(hAxes32,'Ylim',[-1 1]);
hold on;
plot(tcf,acf3);
grid minor;
%ВКФ
ccf13=xcorr(S1,S3,'coeff');
axes(hAxes13);
ylim([-1 1]);
hold on;
plot(tcf,ccf13);
grid minor;
ccf23=xcorr(S2,S3,'coeff');
axes(hAxes23);
ylim([-1 1]);
hold on;
plot(tcf,ccf23);
grid minor;
ccf31=xcorr(S3,S1,'coeff');
axes(hAxes33);
ylim([-1 1]);
hold on;
plot(tcf,ccf31);
grid minor;