Homework Eleven: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 7: | Line 7: | ||
For my example of DFT, I have chosen to demonstrate digital filtering. |
For my example of DFT, I have chosen to demonstrate digital filtering. |
||
The process of digital filtering in Matlab is quite simple. To demonstrate this I must first obtain an original signal and I have chosen to use Audacity to create a short, four second clip of an electronic-genre music file. The artist is known as Air and the song I have chosen is "Electronic Performers." After this, I had to create a noisy signal and to accomplish this I simply super-imposed a sum of sine and cosine waves over the original signal (i.e. I literally added noise to my original signal). This is the Matlab code I used to accomplish these tasks: |
|||
<pre> |
|||
close all; |
|||
clear all; |
|||
% Constants to scale noise |
|||
a = 50; % noise amplitude a |
|||
b = 50; % noise amplitude b |
|||
c = 50; % noise amplitude c |
|||
n = 10000000; % frequency scaling factor |
|||
tune = 'audio1.wav'; % location/name of .WAV file |
|||
[audio fs] = wavread(tune); % turn .WAV file into binary format and get the sampling frequency |
|||
[N C] = size(audio); % Get the number of rows and columns of the audio matrix |
|||
t = 0:(N-1); |
|||
noise = a*sin(fs*t/n) + b*sin(fs*t/n) + c*sin(fs*t/n); % create some noise! |
|||
noise = [noise' zeros(N,1)]; % reformat the noise to match the dimensions of the audio matrix |
|||
noisy = audio + noise; % create the noisy signal by adding the noise to the audio matrix |
|||
% we now have an original signal called "audio" and a noisy signal called "noisy". |
|||
</pre> |
Revision as of 10:59, 16 December 2009
Present an Octave (or Matlab) example using the DFT
For my example of DFT, I have chosen to demonstrate digital filtering.
The process of digital filtering in Matlab is quite simple. To demonstrate this I must first obtain an original signal and I have chosen to use Audacity to create a short, four second clip of an electronic-genre music file. The artist is known as Air and the song I have chosen is "Electronic Performers." After this, I had to create a noisy signal and to accomplish this I simply super-imposed a sum of sine and cosine waves over the original signal (i.e. I literally added noise to my original signal). This is the Matlab code I used to accomplish these tasks:
close all; clear all; % Constants to scale noise a = 50; % noise amplitude a b = 50; % noise amplitude b c = 50; % noise amplitude c n = 10000000; % frequency scaling factor tune = 'audio1.wav'; % location/name of .WAV file [audio fs] = wavread(tune); % turn .WAV file into binary format and get the sampling frequency [N C] = size(audio); % Get the number of rows and columns of the audio matrix t = 0:(N-1); noise = a*sin(fs*t/n) + b*sin(fs*t/n) + c*sin(fs*t/n); % create some noise! noise = [noise' zeros(N,1)]; % reformat the noise to match the dimensions of the audio matrix noisy = audio + noise; % create the noisy signal by adding the noise to the audio matrix % we now have an original signal called "audio" and a noisy signal called "noisy".