# lab 3 - ECE 158 Lab 3: Sample Rate Alteration Eugene...

This preview shows pages 1–6. Sign up to view the full content.

ECE 158 Lab 3: Sample Rate Alteration Eugene Ichinose 1.1 Fs=10 f=1; t=[0:1] x=cos(2*pi*f*t); xd=x[1:L:end]); %The purpose of downsampling is to decrease the sampling rate. This is done %by takeing the original sampling rate and dividing it by factor L; this %becomes the rate of the downsampled signal. Therefore, the downsampled %signal has a sampling rate of the original sampling rate divided by L, or %1/L. 1.2 function [X,freq]=positiveFFT(x,Fs) N=length(x); %get the number of points k=0:N-1; %create a vector from 0 to N-1 T=N/Fs; %get the frequency interval freq=k/T; %create the frequency range X=fft(x)/N; % normalize the data end Fs =10000; n=[0:Fs]; y=cos(2*pi*1000*n/Fs); [YfreqDomain,frequencyRange] = positiveFFT(y,Fs); stem(abs(frequencyRange),abs(YfreqDomain)); xlabel( 'Freq (Hz)' ) ylabel( 'Amplitude' ) title( 'Part 1.2' )

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
ECE 158 Lab 3: Sample Rate Alteration Eugene Ichinose 1.3 Fs=10000; L=1; n=[0:10000]; x=cos(2*pi*1000*n/Fs); y=x(1:L:end); [YfreqDomain,frequencyRange] = positiveFFT(y,Fs); Subplot(2,2,1); stem(abs(frequencyRange),abs(YfreqDomain)); xlabel( 'Freq (Hz)' ) ylabel( 'Amplitude' ) title( 'L=1' ) L=2; x=cos(2*pi*1000*n/Fs); [YfreqDomain,frequencyRange] = positiveFFT(y,Fs); Subplot(2,2,2); stem(abs(frequencyRange),abs(YfreqDomain)); xlabel( 'Freq (Hz)' ) ylabel( 'Amplitude' ) title( 'L=2' ) L=4; x=cos(2*pi*1000*n/Fs); y=x(1:L:end); [YfreqDomain,frequencyRange] = positiveFFT(y,Fs); Subplot(2,2,3); stem(abs(frequencyRange),abs(YfreqDomain)); xlabel( 'Freq (Hz)' ) ylabel( 'Amplitude' )
ECE 158 Lab 3: Sample Rate Alteration Eugene Ichinose title( 'L=4' ) L=8; x=cos(2*pi*1000*n/Fs); y=x(1:L:end); [YfreqDomain,frequencyRange] = positiveFFT(y,Fs); Subplot(2,2,4); stem(abs(frequencyRange),abs(YfreqDomain)); xlabel( 'Freq (Hz)' ) ylabel( 'Amplitude' ) title( 'L=8' )

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
ECE 158 Lab 3: Sample Rate Alteration Eugene Ichinose 1.3 cont. 1.4 When L=8, the original frequency of the signal is divided by a factor of 8. Therefore, the frequency of the downsampled tone at L=8 is Fs/L, or 10,000Hz/8, which is 1.25 kHz. 1.5 y = imread( 'barbaraLarge.gif' ); %read the signal y from the image file L = 2; %define the downsampling factor
ECE 158 Lab 3: Sample Rate Alteration Eugene Ichinose [rows,columns] = size(y); %get the number of rows and columns in the image; yd = zeros(floor(rows/L),floor(columns/L)); %Find the new signal yd that is downsampled by factor L for i=1:floor(rows/L), for j=1:floor(columns/L), %select one sample from each 2row&2column block yd(i,j) = y((i-1)*L+1, (j-1)*L+1); %insert this sample in yd

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 11/01/2011 for the course ANTHRO 5 taught by Professor Gaulin during the Spring '11 term at San Diego.

### Page1 / 12

lab 3 - ECE 158 Lab 3: Sample Rate Alteration Eugene...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online