% The University of Queensland % School of Information Technology & Electrical Engineering % COMS3100/7100 Introduction to Communications % Read a section of an audio clip and display three plots illustrating % the difference between continuous-time/analogue, discrete-time and % digital signals % Read in the clip [x, Fs] = wavread('clean-clip.wav'); % Select a bit that looks interesting start = 50000; len = Fs/20; ct = x(start:(start+len), 1); % Plot the continuous-time signal figure(1); clf; plot(0:(1/Fs):(len/Fs), ct); ylim([-0.8, 0.8]); xlabel('\itt'); ylabel('\itx\rm(\itt\rm)'); % Convert to discrete-trime by sampling (actually, by grossly undersampling, % but we'll come to that later in the course). dt = ct(1:100:length(ct)); % Plot it figure(2); clf; stem(dt, 'filled', 'g'); axis tight; h = gca; set(h, 'XTick', 1:length(dt), 'XGrid', 'on'); ylim([-0.8, 0.8]); xlabel('\itn'); ylabel('\itx\rm[\itn\rm]'); % Now quantise the amplitudes to create a `digital' signal (of course, all % the data is already in stored in the computer and so must be digital % already, but we exaggerate the quantisation here). Here, we quantise % to the nearest multiple of 0.2. dig = 0.2 * round(dt / 0.2); % plot it again figure(3); clf; stem(dig, 'filled', 'r'); axis tight; h = gca; set(h, 'XTick', 1:length(dt), 'XGrid', 'on', 'YTick', -0.8:0.2:0.8, ... 'YGrid', 'on'); ylim([-0.8, 0.8]); xlabel('\itn'); ylabel('\itx\rm[\itn\rm]');