There is quadrature detector which receive radio signal and return its amplitude and instantaneous phase after performing hilbert transformation and transferring the signal to zero frequency. The main purpose of this device is save information about phase of received signal after digitizing (here is example of such receiver). Simplified structure of such detector shown below:

enter image description here

The following octave code try emulating the detector (I'm not sure that is correct):

% Prepare to work.
close all;
clear all;

% Main constant.
frequency_local_oscillator = 30e6;
frequency_intermediate     = frequency_local_oscillator;
frequency_sampling         = frequency_intermediate * 4;
time_begin                 = 0;
time_end                   = 10e-4;
time                       = linspace (time_begin, time_end, frequency_sampling * (time_end - time_begin) );
size                       = length (time);

% Pulse.
magnitude_pulse            = 1.0;
phase_pulse                = 0;
carrier_pulse              = magnitude_pulse * cos (2 * pi * frequency_intermediate .* time + phase_pulse);
timeshift_pulse            = time_begin + (time_end - time_begin) / 4;
duration_pulse             = (time_end - time_begin) / 2;
envelope_pulse = zeros (1, size);
envelope_pulse = envelope_pulse + heaviside (time - timeshift_pulse) .* heaviside (duration_pulse - time + timeshift_pulse);
signal_pulse   = carrier_pulse .* envelope_pulse;
if 0 % Make signal more realistic.
% Noise.
magnitude_noise            = 0.01;
carrier_noise              = magnitude_noise * randn (1, size);
signal                     = signal_pulse + carrier_noise;
signal                     = signal_pulse;

% Moving to zero frequency and and quadrature detection.
signal_i =  signal .* cos (2 * pi * frequency_local_oscillator * time);
signal_q = -signal .* sin (2 * pi * frequency_local_oscillator * time);

% LPF.
[b a] = ellip (4, 0.1, 60, 0.1);
signal_i_filtered = filter (b, a, signal_i);
signal_q_filtered = filter (b, a, signal_q);

% Decimation (performed at two stages with common ratio: 15 х 16 = 240).
signal_i_decimated = decimate (signal_i_filtered,  15);
signal_q_decimated = decimate (signal_q_filtered,  15);
signal_i_decimated = decimate (signal_i_decimated, 16);
signal_q_decimated = decimate (signal_q_decimated, 16);
% Time scale after decimation.
time_decimated = linspace (time_begin, time_end, length (signal_i_decimated) );

% Magnitude and instantaneous phase.
signal_magnitude = sqrt  (signal_i_decimated .^ 2 + signal_q_decimated .^ 2);
signal_phase     = atan2 (signal_q_decimated, signal_i_decimated);

% Display signal.
grid on;
subplot (2, 1, 1);
plot (time, signal, 'b');
hold on;
plot (time, envelope_pulse, 'r');
title ("Input signal.");
xlabel ("Time [s].");
ylabel ("Magnitude [V].");
subplot (2, 2, 3);
plot (signal_magnitude, 'b');
title ("Magnitude of the signal.");
xlabel ("Sample number.");
ylabel ("Magnitude [V].");
subplot (2, 2, 4);
plot (signal_phase, 'g');
title ("Phase of the signal.");
set (gca, 'YTick',     -pi: pi / 2: pi)
set (gca, 'YTickLabel',{'-pi', '-pi / 2', '0', 'pi / 2','pi'})
xlabel ("Sample number.");
ylabel ("Phase [rad].");

Here is result of the code which looks in my opinion more or less real: enter image description here

I have records of two different signals from output of the detector (desired signal and noise). And now I'd like to adding those signals (combine as if they was received simultaneously). Is it possible to do it and how can I do this?
The main purpose of this task is performing measurements of the the once recorded signal with different calibrated noises.

My attempts:
About possibility I think it's possible if all stages of the detector are linear. If it is true this allows swap processing stages.

In my opinion add together magnitudes and phases of signals is wrong. I think that this task can be solved with the following steps:

  • revert conversion at I and Q;
  • get sum of components of two signals;
  • convert I and Q to magnitude and phase again.

Am I right?

  • $\begingroup$ I don't understand the question. You seem to have two signals in polar coordinates, and you want to add them. What is the problem? Please clarify. $\endgroup$
    – MBaz
    Nov 8, 2015 at 1:05
  • $\begingroup$ This question makes very little sense. Can you please explain what this system is supposed to achieve? What do you mean by "mixing"? That could just mean multiplication. I'm closing this question until you clarify. $\endgroup$
    – Peter K.
    Nov 8, 2015 at 1:15
  • $\begingroup$ @MBaz, Yes you are right! I have two signals in polar coordinates (magnitude and phase) and I want to add them each other. I've updated my question and added several links (at the beginning of the question). $\endgroup$
    – Gluttton
    Nov 8, 2015 at 8:03
  • $\begingroup$ It is possible to add samples in polar coordinates. It is also possible to convert them to rectangular and then add them. Both are equivalent. $\endgroup$
    – MBaz
    Nov 8, 2015 at 19:22
  • 1
    $\begingroup$ @Glutton See math.stackexchange.com/questions/1365622/… $\endgroup$
    – MBaz
    Nov 9, 2015 at 19:26

1 Answer 1


Mixing is not the correct terminology for what you want to do. Mixing is multiplication and you want additive noise. Convert back to I/Q, add complex noise, then convert back to mag/phase!

  • $\begingroup$ Mixing is not the correct terminology for what you want to do. - thanks, I've updated my question. Convert back to I/Q, add complex noise, then convert back to mag/phase! - how you know it (do you have some usage experience or theoretical background)? $\endgroup$
    – Gluttton
    Nov 9, 2015 at 18:33
  • $\begingroup$ I have both usage and theoretical background. Typically, I keep my data as a complex array as most operations make sense in this manner, i.e., filtering, adding noise (most math function in Matlab, Octave, Numpy - my personal favourite - will operate on complex arrays). @MBaz is correct as well, you don't actually need to switch back and forth - I just find I/Q pairs the natural way to do it for me. $\endgroup$
    – johnnymopo
    Nov 9, 2015 at 19:51
  • $\begingroup$ I don't have any DSP books on me, other wise I would reference one. I'll try later $\endgroup$
    – johnnymopo
    Nov 9, 2015 at 19:55

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.