Code covered by the BSD License
 AD_DA(x,Xmin,Xmax,Levels)
This function represents an A/D converter in series with a D/A converter
 conv_DHT(x,y)
Linear Convolution calculated via the Discrete Hartley Transform (DHT).
 conv_DHT2(x,h)
Linear Convolution Calculated via the Discrete Hartley Transform (DHT).
 decimator(x,h,K)
This function performs decimation on the input signal x[n]
 diffft(x)
DecimationInFrequency (DIF) FFT.
 fastconv(x,y)
Compute a linear (or circular, depending on relative signal lengths) convolution via DFT's.
 fastconv2(x,y)
Compute a linear convolution via DFT's.
 fastconv3(x,y,nx,ny)
Compute a linear convolution via DFT's.
 fastconvreal(x,y)
Compute the linear convolution of 2 real sequences via FFT's.
 fastconvreal2(x,y,nx,ny)
Compute the linear convolution of 2 real sequences via FFT's.
 fft241(x,y)
This function calculates the DFT's of two real Npoint sequences, by means of
 fftreal(x)
This function calculates the FFT of an Npoint real signal x[n] by use
 fraction_delay(x, h, N)
This function induces a fractional sample delay by 1/N to the input signal x.
 fraction_delay3(x, h1, M,...This function induces a fractional sample delay by M/L to the input signal x.
 fraction_sample(x,h,M,N)
Fractional Sampling Rate Conversion function by a factor of M/N.
 ifft241(X,Y)
This function calculates the IDFT's of 2 given complex DFT sequences of common length N,
 ifftreal(X)
This function computes the ifft of an Npoint complex DFT sequence which corresponds
 ifftreal2(X)
This function computes the ifft of an Npoint complex DFT sequence which corresponds
 interpolator(x,h,L)
This function performs interpolation on the input signal x[n]
 method2_idft(X)
 method3_idft(X)
 my_CTFT(x,dt,freq_type)
Continuous Time Fourier Transform Approximation.
 my_CZT(x,M,W,A)
Fast chirp ztransform (CZT) computation.
 my_Co_IDCT(X)
Inverse Discrete Cosine Transform Computation.
 my_DCT(x)
Discrete Cosine Transform Computation.
 my_DCT_2D(X)
Twodimensional DCT computation.
 my_DFT(x)
This function calculates the DFT of the input signal x.
 my_DFT2(x)
Direct DFT Computation using the definition formula.
 my_DHT(x)
This function calculates the Discrete Hartley Transform of a real
 my_DHT2(x,time_ind)
This function calculates the Discrete Hartley Transform of a real
 my_DHT3(x)
This function calculates the Discrete Hartley Transform of a real
 my_DTFT(x,n)
DTFT Computation using the definition formula.
 my_DTFT2(x,n,w)
DTFT Computation using the definition formula.
 my_DTFT3(x,n1)
DTFT Computation using the definition formula.
 my_DTFT4(x,n)
DTFT Computation using the matrix multiplication method.
 my_FFT_2D(X)
Twodimensional DFT computation.
 my_IDCT(X)
Inverse Discrete Cosine Transform Computation.
 my_IDCT_2D(X)
Twodimensional Inverse DCT computation.
 my_IDFT(X)
This function calculates the Inverse DFT of the input signal X.
 my_IFFT_2D(X)
Twodimensional Inverse FFT computation.
 my_Re_IDCT(X)
Discrete Cosine Transform Computation.
 my_conv(x,h,nx,nh)
This function computes the linear convolution of input signals x[n] and h[n].
 my_conv2(x,h,nx,nh)
This function computes the linear convolution of input signals x[n] and h[n].
 my_downsample(x,M)
This function performs downsampling to input row vector x
 my_spectrogram(x,Fs,N,M,w...This function calculates the spectrogram of the input signal x.
 my_upsample(x,N)
This function performs upsampling to input row vector x
 overlap_add(x,h,half_segm...Linear Convolution computation by use of overlapandadd method.
 overlap_save(x,h,segment_...Linear Convolution computation via the OverlapandSave method.
 overlap_save2(x,h,segment...Linear Convolution computation via the OverlapandSave method. Version 2.
 radix2fft(x)
Radix2, DecimationInTime (DIT), FFT Computation function.
 radix4fft(x)
Radix4, DecimationInTime (DIT), FFT Computation function.
 shiftdown(x,n)
This function shifts down (up) the contents of a column vector
 shiftright(x,n)
This function shifts to the right (left) the contents of a row vector
 splitradixfft(x)
SplitRadix, DecimationInTime (DIT),FFT Computation function.
 uniform_quantizer(x,L,max...This function implements a uniform quantizer of L levels.
 zero_phase_dft(x)
This function is an implementation of the "zero phase DFT" of a given
 zero_phase_dtft(x,M)
This function is an implementation of the "zero phase DTFT" of a given
 bench_dtft.mThis routine compares the time needed to execute various DTFT implementations.
 ex213.m
 ex214.mExercise 2.1.4. Time Axis Alteration.
 ex216.mExercise 2.1.6. The Geometric Series.
 ex217.mExercise 2.1.7. Characteristics of Signals.
 ex231.mExercise 2.3.1. The Convolution Sum.
 ex232.m
 ex233.mExercise 2.3.3. Introduction to Graphical Convolution.
 ex234.mExercise 2.3.4. Convolving Sequences.
 ex235.mExercise 2.3.5. More Convolution.
 ex236.mExercise 2.3.6. Beginning and End Points.
 ex245.mExercise 2.4.5. Nonlinear Difference Equations.
 ex246.mExercise 2.4.6. Autocorrelation.
 ex247.mExercise 2.4.7. CrossCorrelation.
 ex248.mExercise 2.4.8. Random Sequences.
 ex249.mExercise 2.4.9. Gaussian Random Sequences.
 ex311.m
 ex3110.m
 ex3111.m
 ex312.m
 ex314.mExercise 3.1.4. Hermitian Symmetry.
 ex315.mExercise 3.1.5. Periodicity of the DiscreteTime Fourier Transform.
 ex316.mExercise 3.1.6. The Shift Property.
 ex317.mExercise 3.1.7. The Modulation Property.
 ex318.m
 ex319.m
 ex321.mExercise 3.2.1. Digital Filters.
 ex322.m
 ex323.m
 ex324.mExercise 3.2.4. Filtering a Sinusoid and a Random Sequence.
 ex331.m
 ex332.m
 ex333.m
 ex411.mExercise 4.1.1. Ideal Sampling (Frequency Domain).
 ex412.m
 ex413.mExercise 4.1.3. Ideal Reconstruction (Frequency Domain).
 ex414.mExercise 4.1.4. Commercial D/A Converters.
 ex415.m
 ex421.mExercise 4.2.1. Quantization.
 ex422.m
 ex423.m
 ex424.m
 ex431.mExercise 4.3.1. Downsampling.
 ex432.mExercise 4.3.2. Aliasing in Downsampling.
 ex433.mExercise 4.3.3. Upsampling.
 ex435.m
 ex436.m
 ex437.m
 ex438.m
 ex5110.mExercise 5.1.10. Stability.
 ex5111.m
 ex513.mExercise 5.1.3. Producing Pole/Zero Plots.
 ex518.mExercise 5.1.8. Finding System Functions from Poles and Zeros.
 ex519.m
 ex521.mExercise 5.2.1. Finding the Inverse zTransform.
 ex5210.mExercise 5.2.10. Convolution.
 ex522.m
 ex524.mExercise 5.2.4. Computing the Inverse zTransform.
 ex525.m
 ex527.m
 ex528.mExercise 5.2.8. Modulation.
 ex541a.mExercise 5.4.1.a. Sketching the Magnitude Response.
 ex541b.mExercise 5.4.1.b. Sketching the Magnitude Response.
 ex542a.mExercise 5.4.2.a. Sketching Magnitude Responses from Pole/Zero Plots.
 ex542b.mExercise 5.4.2.b. Sketching Magnitude Responses from Pole/Zero Plots.
 ex542c.mExercise 5.4.2.c. Sketching Magnitude Responses from Pole/Zero Plots.
 ex542d.mExercise 5.4.2.d. Sketching Magnitude Responses from Pole/Zero Plots.
 ex542e.mExercise 5.4.2.e. Sketching Magnitude Responses from Pole/Zero Plots.
 ex544.mExercise 5.4.4. Poles and Zeros at Infinity.
 ex545a.m
 ex545b.mExercise 5.4.5.b. Determining Poles and Zeros from the DTFT.
 ex546.mExercise 5.4.6. Interaction of Poles and Zeros.
 ex611.mExercise 6.1.1. Some Simple DFT Properties.
 ex612.mExercise 6.1.2. Direct DFT Evaluation.
 ex613.m
 ex614.mExercise 6.1.4. Spatial Aliasing.
 ex621.mExercise 6.2.1. Introduction to Circular Shifting.
 ex622.mExercise 6.2.2. Circular Convolution.
 ex623.mExercise 6.2.3. Circular and Linear Convolutions.
 ex624.mExercise 6.2.4. Linear Convolutions via Circular Convolutions.
 ex625.mExercise 6.2.5. Circular Shift.
 ex626.mExercise 6.2.6. Circular Modulation.
 ex631.m
 ex632.m
 ex633.mExercise 6.3.3. Computational Complexity of the FFT.
 ex634.m
 ex635b.m
 ex635c.m
 ex636.mExercise 6.3.6. FFT for Real Input Sequences.
 ex637.mExercise 6.3.7. Goertzel's Algorithm.
 ex641.mExercise 6.4.1. Evaluating Linear Convolutions Using the DFT.
 ex642.mExercise 6.4.2. OverlapandAdd Method.
 ex643.mExercise 6.4.3. Extracting Good Values from Circular Convolutions.
 ex644.mExercise 6.4.4. Overlap and Save Method.
 ex645.mExercise 6.4.5. Use of the DFT for Deconvolution.
 ex651.m
 ex653.mExercise 6.5.3. The Discrete Cosine Transform (DCT).
 ex654.mExercise 6.5.4. The Discrete Hartley Tranform.
 ex655.mExercise 6.5.5. Transform Coding.
 ex656.m
 hartley.mRelation of Hartley Transform with DFT:
 spectro_demo.mShortTime Fourier Transform (Spectrogram) Demo.
 test_fastconv3.mThis program tests function fastconv3.m to ensure its proper functionality.
 test_idct.mTest fot my_DCT.m and my_IDCT.m scripts.
 test_idct2D.mTesting the my_DCT.m and my_IDCT.m on an image
 test_ifft241.mTest custom function: ifft241.m

View all files
MatLab Solutions: "Introduction to Digital Signal Processing: A Computer Laboratory Textbook".
by
Ilias Konsoulas
29 Oct 2012
(Updated
25 Nov 2013)
These files are the MatLab solutions of exercises contained in the above DSP lab textbook.

AD_DA(x,Xmin,Xmax,Levels)

function y = AD_DA(x,Xmin,Xmax,Levels)
% This function represents an A/D converter in series with a D/A converter
% for the sake of exercise 4.2.2. where quantization effects are studied.
% Unlike the textbook instructions, here the input signal x is assumed
% already sampled with Ts = 1msec. Therefore, no sampling operation
% takes place here.
% Quantization of the input signal x:
xq = uniform_quantizer(x,Levels,Xmax,Xmin);
% The quantized signal xq is also assumed to exist in analog time
% and therefore it constitutes a weighted impulse train as described
% in the textbook's macro. No "sti" conversion required.
% Filter the "analogue" impulse train xq(t) with lowpass IIR filter hh[n]:
hh_b = [0.007170507 0.01914651 0.03186915 0.03505794 0.03186915 0.01914651 0.007170507];
hh_a = [1 4.716277 9.676021 10.97638 7.236803 2.623675 0.4082634];
% Insert some zeros at the end of xq to make it suitable for filter command:
xq = [xq zeros(1,20)];
ya = filter(hh_b,hh_a,xq);
% Extract the block of interest:
y = ya(8:108);


Contact us