% class1 - script used in first ECE 201 class %% DJIA data % begin by importing DJIA data from file djia.csv; use "Import Data ..." in % "File" menu % define length 50 running average filters to be used for smoothing M = 50; b = ones(1,M)/M; M2 = 15; b2 = ones(1,M2)/M2; % extract "Close" data after import ... djia = flipud(data(:,4)); dates = datenum(flipud(textdata(2:end,1))); % ... then plot plot(dates,djia) datetick('x','yyyy') xlabel('Time'); ylabel('DJIA') grid pause % filter data for smoother signals smooth = conv(b,djia); smooth2 = conv(b2,djia); hold on; plot(dates(51:end,1), smooth(51:length(djia)), 'r'); plot(dates(51:end,1), smooth2(51:length(djia)),'g'); hold off; % prepare for next example disp('press return for next example'); pause close(gcf) %% Music % load sampled signal from wav file [y,fs,nbits] = wavread('music.wav'); % display sample rate and resolution of wav file ... disp(sprintf('Fs: %5.0f\nNbits: %2d\n',fs,nbits)) % ... then play through speaker, and ... soundsc(y,fs) disp('press return for plot') pause % plot and play again after pause t = (1:length(y))/fs; % time axis plot(t,y) xlabel('Time (seconds)') ylabel('Signal Amplitude') disp('press return for sound') pause soundsc(y,fs) disp('press return for next example'); pause close(gcf) %% Heart beat signal % read signal from wav file [y,fs,nbits] = wavread('heart.wav'); % display sample rate and resolution disp(sprintf('Fs: %5.0f\nNbits: %2d\n',fs,nbits)) % play through speaker soundsc(y,fs) disp('press return for plot') pause % plot and play again after pause t = (1:length(y))/fs; % time axis plot(t,y) xlabel('Time (seconds)') ylabel('Signal Amplitude') disp('press return for sound') pause soundsc(y,fs) disp('press return to end'); pause close(gcf)