úterý 19. října 2010

CZS cvičení 4(Matlab)

A=1.5;
fs=200;
f=14;
t0=20;

% sinusovka 1
t = 0:1/fs:t0;
s1 = 0.5*sin(2*pi*t*14);

% sinusovka 2
t = 0:1/fs:t0;
s2 = 0.43*sin(2*pi*t*27.5);

signal = s1 + s2;



figure(1);
subplot(311);
plot(signal);
subplot(312);
NDFT = 256;
plot(abs(fft(signal,NDFT)));
subplot(313);
spectrogram(signal,NDFT,[],[],fs,'yaxis'); % normální zobrazení
% ,[] zde budou vložení defaultní hodnoty

signal = randn(4000,1); % Gausovský šum

figure(2);
subplot(311);
plot(signal);
subplot(312);
NDFT = 256;
plot(abs(fft(signal,NDFT)));
subplot(313);
spectrogram(signal,NDFT,[],[],fs,'yaxis');


n=randn(1,4001);
% SNR = 10 log(vykonz uzit. signalu/sumu)
Ps=mean(s1.^2); %stredni hodnota kvadratu s
Pn=mean(n.^2);
SNR=10*log10(Ps/Pn);
SNR1=10;
k = sqrt(Ps/Pn * 10^(-SNR1/10));
signal = k * n + s1; % Gausovský šum

figure(3);
subplot(311);
plot(signal);
subplot(312);
NDFT = 256;
plot(abs(fft(signal,NDFT)));
subplot(313);
spectrogram(signal,NDFT,[],[],fs,'yaxis');

signal = load('EEG.asc');
figure(4);
subplot(311);
plot(signal);
subplot(312);
NDFT = 256;
plot(abs(fft(signal,NDFT)));
subplot(313);
spectrogram(signal,NDFT,[],[],fs,'yaxis');

signal = loadbin('sm2.bin');
figure(5);
subplot(311);
plot(signal);
subplot(312);
NDFT = 256;
plot(abs(fft(signal,NDFT)));
subplot(313);
spectrogram(signal,NDFT,[],[],fs,'yaxis');

signal = loadbin('sf2.bin');
figure(6);
subplot(311);
plot(signal);
subplot(312);
NDFT = 256;
plot(abs(fft(signal,NDFT)));
subplot(313);
spectrogram(signal,NDFT,[],[],fs,'yaxis');

signal = loadbin('sm1.bin');
figure(7);
subplot(311);
plot(signal);
subplot(312);
NDFT = 256;
plot(abs(fft(signal,NDFT)));
subplot(313);
spectrogram(signal,NDFT,[],[],fs,'yaxis');

signal = loadbin('sf1.bin');
figure(8);
subplot(311);
plot(signal);
subplot(312);
NDFT = 256;
plot(abs(fft(signal,NDFT)));
subplot(313);
spectrogram(signal,NDFT,[],[],fs,'yaxis');

signal = loadbin('piano_d_dur_4.wav');
figure(9);
subplot(311);
plot(signal);
subplot(312);
NDFT = 256;
plot(abs(fft(signal,NDFT)));
subplot(313);
spectrogram(signal,NDFT,[],[],fs,'yaxis');

signal = loadbin('housle_d_dur_5.wav');
figure(10);
subplot(311);
plot(signal);
subplot(312);
NDFT = 256;
plot(abs(fft(signal,NDFT)));
subplot(313);
spectrogram(signal,NDFT,[],[],fs,'yaxis');

signal = load('EEG.asc');
figure(11);
subplot(311);
plot(signal);
subplot(312);
NDFT = 256;
plot(pwelch(signal));
subplot(313);
spectrogram(pwelch(signal),NDFT,[],[],fs);
http://noel.feld.cvut.cz/vyu/a2m99czs/cv_Spectrum.html

Žádné komentáře:

Okomentovat