# lab 3 - 1.1 Fs=10 f=1 t=[0:1 x=cos(2*pi*f*t...

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

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 =10; n=[0:10]; y=cos(2*pi*1*n/Fs); [YfreqDomain,frequencyRange] = positiveFFT(y,Fs); stem(abs(frequencyRange),abs(YfreqDomain)); xlabel( 'Freq (kHz)' ) ylabel( 'Amplitude' ) title( 'Part 1.2' ) 1.3

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

View Full Document
Fs=10000; L=8; n=[0:10000]; x=cos(2*pi*1000*n/Fs); y=x(1:L:end); [YfreqDomain,frequencyRange] = positiveFFT(y,Fs/L); stem(abs(frequencyRange),abs(YfreqDomain)); xlabel( 'Freq (Hz)' ) ylabel( 'Amplitude' ) title( 'L=8' ) 1.5 y = imread( 'barbaraLarge.gif' ); %read the signal y from the image file L = 2; %define the downsampling factor [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 end end %configure the output image(below) figure( 'Position' ,[100 100 size(y,2) size(y,1)], ... 'MenuBar'

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.

{[ snackBarMessage ]}

### Page1 / 9

lab 3 - 1.1 Fs=10 f=1 t=[0:1 x=cos(2*pi*f*t...

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

View Full Document
Ask a homework question - tutors are online