gnuplot_binary ("/opt/local/bin/gnuplot") %load -ascii tek0005CH1.csv % Decide where the two samples are T_signal = 500000:504000; % signal + noise T_noise = 400000:404000; % noise only % Find the sampling period, assuming it is constant T_samp = tek0005CH1(2, 1) - tek0005CH1(1, 1); wavwrite("output.wav", tek0005CH1(:,2), 1/T_samp, 16 ); figure(1); subplot(2,1,1); plot(T_signal, tek0005CH1(T_signal, 2)) title('Signal and Noise Time Domain'); subplot(2,1,2); plot(T_noise, tek0005CH1(T_noise, 2)) print -djpg signal_noise_time_domain.jpg fft_signal = fft(tek0005CH1(T_signal, 2)); fft_noise = fft(tek0005CH1(T_noise, 2)); fft_length = size(fft_signal,1)+1; BANDDIV = 2.5; % take this fraction of the bandwidth fft_domain = 1:(fft_length/2/BANDDIV); fft_freq = linspace(1, 1/T_samp/2/BANDDIV, fft_length/2/BANDDIV); figure(2); subplot(2,1,1); semilogy(fft_freq, abs(fft_signal(fft_domain) )); title('Signal and Noise Energy Spectrum'); subplot(2,1,2); semilogy(fft_freq, abs(fft_noise(fft_domain) )); print -djpg signal_noise_freq_domain.jpg