latihan baca suara dimatlab.docx

3
>> [ y, fs] = wavread('REKAMAN 1.wav'); %membaca data rekaman >> sound (y,fs); %play data rekaman >> y = y(:,1); >> dt = 1/fs; >> t = 0:dt:(length(y)*dt)-dt; >> plot(t,y); xlabel('Seconds'); ylabel('Amplitude'); >> figure % meanmpilkan data rekaan suara ke bentuk grafik 0 5 10 15 20 25 -0.5 -0.4 -0.3 -0.2 -0.1 0 0.1 0.2 0.3 0.4 0.5 S econds Amplitude >> plot(psd(spectrum.periodogram,y,'Fs',fs,'NFFT',length(y)));

description

latihan matlab

Transcript of latihan baca suara dimatlab.docx

Page 1: latihan baca suara dimatlab.docx

>> [ y, fs] = wavread('REKAMAN 1.wav'); %membaca data rekaman

>> sound (y,fs); %play data rekaman

>> y = y(:,1);

>> dt = 1/fs;

>> t = 0:dt:(length(y)*dt)-dt;

>> plot(t,y); xlabel('Seconds'); ylabel('Amplitude');

>> figure % meanmpilkan data rekaan suara ke bentuk grafik

0 5 10 15 20 25-0.5

-0.4

-0.3

-0.2

-0.1

0

0.1

0.2

0.3

0.4

0.5

Seconds

Am

plitu

de

>> plot(psd(spectrum.periodogram,y,'Fs',fs,'NFFT',length(y)));

Page 2: latihan baca suara dimatlab.docx

0 5 10 15 20-200

-180

-160

-140

-120

-100

-80

-60

-40

-20

0

Frequency (kHz)

Pow

er/fr

eque

ncy

(dB

/Hz)

Periodogram Power Spectral Density Estimate

% mengetahui nilai fs

>> fs

fs =

44100

>> NFFT = 2^nextpow2(1000); % Next power of 2 from length of y

>> Y = fft(y,NFFT)/1000;

>> f = 44100/2*linspace(0,1,NFFT/2+1);

>> plot(f,2*abs(Y(1:NFFT/2+1)))

>> title('Single-Sided Amplitude Spectrum of y(t)')

>> xlabel('Frequency (Hz)')

Page 3: latihan baca suara dimatlab.docx

>> ylabel('|Y(f)|')

0 0.5 1 1.5 2 2.5

x 104

0

0.005

0.01

0.015

0.02

0.025

0.03

0.035Single-Sided Amplitude Spectrum of y(t)

Frequency (Hz)

|Y(f)

|