I am trying to implement sampling and reconstruction using simulink and as far amplitude(magnitude) values are concerned ,i have exactly same values but there appears phase shift when i try to see both original input signal and final reconstructed signal on same scope

My Matlab code

% f - The frequency of analog sinosoid signal
% F - Sampling Rate
% qbits - Number of Quantizations bits
% A - Amplitude of sinusoid signal
% L - Number of quantization levels based on qbits
% I - Quantization Interval
% sim_time - Simultaion Time
% span - x-axis range of frequency plot 1 & 3 (spectrum scope 1 & 3)
% span1 - x-axis range of frequency plot 2 (spectrum scope 2)
% NFFT - Number of FFT points

close all;

f = input('Enter the frequency of signal = ');
F = input('Enter the sampling frequency = ');
A = input('Enter max amplitude of signal = ');
qbits = input('Enter the number of quantization bits = ');
fc = input('Enter the lowpass filter cutoff frequency = ');

L = 2^qbits;
I = 2*A/(L-1); 

% Settings for Spectrum Scope
span = 8*F;
span1 = 8*F;
NFFT = 256;

% To run simulink model
t = 1/f;
sim_time = 10*t; 

Link of simulink file https://file.io/zHdipj8VjpoN

I have also attached a snapshot of this simulink model and red encircled the last scope on right side(scope 2) which is showing both original input signal and reconstructed signal enter image description here

  • 1
    $\begingroup$ Each of the blocks at the bottom of the diagram introduces a delay (phase shift). $\endgroup$
    – MBaz
    Commented May 17, 2022 at 15:34
  • 1
    $\begingroup$ you explicitly have a butterworth filter in there. You know that this must have a phase shift! $\endgroup$ Commented May 17, 2022 at 16:03

1 Answer 1


As @MBaz mentioned, you have a zero-order-hold block that introduces a delay + a sample time block that can introduce a delay depending on its settings. Not sure about the Encoder and Decoder block, maybe they can also introduce some delay. You'd have to check the details of theses blocks.

Finally, as @Marcus_Muller mentioned you also have a Butterworth filter that will introduce a delay.

One solution would be to add a lump delay and add the Butterworth filter to the reference signal to align the delays.

  • $\begingroup$ Sample time block?? Do you mean rate transition block?? $\endgroup$
    – DSP_CS
    Commented May 17, 2022 at 17:17
  • $\begingroup$ yeah rate transition block $\endgroup$
    – Ben
    Commented May 17, 2022 at 17:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.