% ...1 means "constant tone" % ...2 means "pitch" %--------------------------------------------- clear all % load andreas_constant_tone_10second; % load alex_constant_tone_10second; load vince_constant_tone_10second; x = A; clear A; n = [1:length(x)]; Ts = 1./(40e3); plot(n,x) N = 40000; n1 = 20000; n2 = 300000; % Cut out 1 s of "control data": x0 = x(n1:n1-1+N); X = fft(x0); S0 = abs(X).^2; % Cut out 1 s of voice data: x1 = x(n2:n2-1+N); X = fft(x1); S1 = abs(X).^2; %====================== Plot results ==================== figure(1) plot(n,x) xlabel('n') ylabel('y([n]') figure(2) semilogy([2:N/2]/(N*Ts),S0(2:N/2),'b-') hold on semilogy([2:N/2]/(N*Ts),S1(2:N/2),'r-') xlim([10 4000]) xlabel('Frequency [Hz]') ylabel('Power spectrum [arb. units]') hold off