clear all % USTAW CZAS POMIARU [s] l_sek_pom = 5; fs = 48000 ; lBit = 24 ; lKan = 2 ; kal_kan_1=0.408/100; kal_kan_2=0.811/100; ID = -1; % domyślny mikrofon recObj = audiorecorder(fs,lBit,lKan,ID); recordblocking(recObj,l_sek_pom); y = getaudiodata(recObj); for (i=1:1:length(y)) yt(i,1) = i/fs; end yt(:,2)=y(:,1)/kal_kan_1; yt(:,3)=y(:,2)/kal_kan_2; % Widma sygnałów L=(l_sek_pom*fs);% długość transformaty widmo_1 = abs(fft(yt(:,2)/(L/2)));% transformacja Fouriera sygnału z kanału 1 widmo_2 = abs(fft(yt(:,3)/(L/2)));% transformacja Fouriera sygnału z kanału 1 f=0:1/l_sek_pom:fs/2-1/l_sek_pom;% wygenerowanie osi częstotliwości % Wykresy figure('NumberTitle', 'off', 'Name', 'Wykresy','Renderer', 'painters', 'Position', [20 50 1500 700]) subplot(4,1,1); plot(yt(:,1),yt(:,2)); title('Kanał nr 1'); xlabel('t [s]'); ylabel('a_1 [m/s^2]'); subplot(4,1,2); plot(yt(:,1),yt(:,3)); title('Kanał nr 2'); xlabel('t [s]'); ylabel('a_2 [m/s^2]'); subplot(4,1,3); plot(f,widmo_1(1:L/2)) title('Widmo kanału 1') xlabel('f (Hz)') ylabel('|A_1| [m/s^2]') xlim([0 8000]) subplot(4,1,4); plot(f,widmo_2(1:L/2)) title('Widmo kanału 2') xlabel('f (Hz)') ylabel('|A_2| [m/s^2]') xlim([0 40])