?? prog14.m
字號:
clear;
clg;
fp=4000;
N=8000;
f1=53;
t=linspace(0,(N-1)/fp,N);
x1=sin(2*pi*f1*t);
x2=square(2*pi*f1*t,70);
x3=chirp(t,100,(N-1)/fp,300);
x4=rand(1,N)-0.5;
x5=randn(1,N);
%wykresy 1
figure(1);
subplot(5,2,1);
plot(t,x1);
ylabel('sinus')
subplot(5,2,3);
plot(t,x2);
ylabel('prostokat')
subplot(5,2,5);
plot(t,x3);
ylabel('chirp')
subplot(5,2,7);
plot(t,x4);
ylabel('rand')
subplot(5,2,9);
plot(t,x5);
ylabel('randn')
%rozk砤d prawdop
k=800;
subplot(5,2,2);
hist(x1,k)
title('gestosc prawdopodobienstwa sinus');
subplot(5,2,4);
hist(x2,k)
title('gestosc prawdopodobienstwa prostokat');
subplot(5,2,6);
hist(x3,k)
title('gestosc prawdopodobienstwa chirp');
subplot(5,2,8);
hist(x4,k)
title('gestosc prawdopodobienstwa rand');
subplot(5,2,10);
hist(x5,k)
title('gestosc prawdopodobienstwa randn');
%wykresy 2
figure(2);
subplot(5,2,1);
plot(t,x1);
ylabel('sinus')
subplot(5,2,3);
plot(t,x2);
ylabel('prostokat')
subplot(5,2,5);
plot(t,x3);
ylabel('chirp')
subplot(5,2,7);
plot(t,x4);
ylabel('rand')
subplot(5,2,9);
plot(t,x5);
ylabel('randn')
%autokorelacja
l=800;
tc=linspace(-l/fp,l/fp,2*l+1);
c1=xcorr(x1,l,'coef');
c2=xcorr(x2,l,'coef');
c3=xcorr(x3,l,'coef');
c4=xcorr(x4,l,'coef');
c5=xcorr(x5,l,'coef');
subplot(5,2,2);
plot(tc,c1);
title('autokorelacja sinus');
subplot(5,2,4);
plot(tc,c2);
title('autokorelacja prostokat');
subplot(5,2,6);
plot(tc,c3);
title('autokorelacja chirp');
subplot(5,2,8);
plot(tc,c4);
title('autokorelacja rand');
subplot(5,2,10);
plot(tc,c5);
title('autokorelacja randn');
%wykresy 3
figure(3);
subplot(5,2,1);
plot(t,x1);
ylabel('sinus')
subplot(5,2,3);
plot(t,x2);
ylabel('prostokat')
subplot(5,2,5);
plot(t,x3);
ylabel('chirp')
subplot(5,2,7);
plot(t,x4);
ylabel('rand')
subplot(5,2,9);
plot(t,x5);
ylabel('randn')
%periodogram
Nf=2048;
subplot(5,2,2);
semilogy(10000000.^periodogram(x1,[],'onesided',Nf,fp));
subplot(5,2,4);
semilogy(10000000.^periodogram(x2,[],'onesided',Nf,fp));
subplot(5,2,6);
periodogram(x3,[],'onesided',Nf,fp);
subplot(5,2,8);
periodogram(x4,[],'onesided',Nf,fp);
subplot(5,2,10);
periodogram(x5,[],'onesided',Nf,fp);
%skala liniowa inaczej: w figure da
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -