% % Homework #2 - Sample Solutions % clear all; % Hahaha. This loads file 'laughter.mat' into variable 'y'. load('laughter') subplot(3,1,1); plot(y) title('Laughter - Original'); % #1 % Play sound clip backwards sound(fliplr(y)); pause % #2 % How many samples? samples = length(y) % #3 % Sub-sample by half. Two acceptable interpretations: y_ds = y(1:2:length(y)); % Downsampled y_half = y(1:length(y/2)); % Sound truncated mid-way through % #4 % Peak Amplitude and its locations peak = max(y) find(y==peak) % #5 % Locations where |amplitude| > 0.8 locations = find(abs(y) > 0.8) % #6 % Number of times |amplitude| > 0.8 occurences = length(locations) % #7 % Set those occurrences to 0.08 y_threshold=y; y_threshold(locations)=0.8; % #8 subplot(3,1,2); plot(y_threshold) xlabel('time'); ylabel('Amplitude'); title('Laughter w/ |amplitude| limited to 0.8'); % #9 % Cut-off the negative band. Two acceptable solutions: y_cutoff = y; y_cutoff(find(y<0))=0; % Cut-off y_cutout = y >= 0; % Cut-out % #10 subplot(3,1,3); plot(y_cutoff) xlabel('time'); ylabel('Ampliude'); title('Laughter w/ amplitudes < 0 cut-off'); sound(y_cutoff);