Phase aliasing ambguity and simulation in MatLab?

TicTek

Newbie level 5
Hello Guys,
So after reading this article Sampling and Aliasing at page 30; I could not reproduce the where the phase has a conjugate value of the origial phase at Fs/2<f<Fs which result in :
fa = Fs − f, fa is the aliased frequency
Za = Z

so my code is here:
Code:
 Fs1=30;  % original sampling frequency
t1=0:1/Fs1:1;
f1=4;ph1=-pi/4;  % signal frequency
x1=sin(2*pi*f1*t1+ph1);   % original signal with original sampling frequency Fs1

Fs2=6;% variable sampling frequency
t1=0:1/Fs1:1;
t2=0:1/Fs2:1;
x2=sin(2*pi*f1*t2+ph1);  % original signal with variable sampling frequency Fs1

subplot(2,1,1)
plot(t1,x1)
subplot(2,1,2)
plot(t2,x2 )

How can I get like him where I can visualize the phase ?

kaz1

Full Member level 2
coding for lowest waveform (Fs = 5 Hz, f = 1hz or 4 Hz)

Fs=5; %sampling frequency
t=0:1/Fs:Fs;
f=1;
ph=+pi/4;
x1=cos(2*pi*f*t+ph);

f = 4;
ph = -pi/4;
x2=cos(2*pi*f*t+ph);

plot(x1);hold;
plot(x2,'r--')

TicTek

Newbie level 5
coding for lowest waveform (Fs = 5 Hz, f = 1hz or 4 Hz)

Fs=5; %sampling frequency
t=0:1/Fs:Fs;
f=1;
ph=+pi/4;
x1=cos(2*pi*f*t+ph);

f = 4;
ph = -pi/4;
x2=cos(2*pi*f*t+ph);

plot(x1);hold;
plot(x2,'r--')
Thank you.
But the theory here says if I change the sampling frequency without changing f(must be set to 4 as constant) we should observe a phase conjugate due to low sampling rate

kaz1

Full Member level 2
Thank you.
But the theory here says if I change the sampling frequency without changing f(must be set to 4 as constant) we should observe a phase conjugate due to low sampling rate
What I see on the waveforms is that:
4Hz @ 30 Fs, no issue of aliasing
4Hz @ 11 Fs, no issue of aliasing
4Hz @ 10 Fs, no issue of aliasing
4Hz @ 6 Fs, aliasing(alias at 2Hz)
4Hz @ 5 Fs, aliasing (alias at 1 Hz)

I took last case and the alias would be at 1Hz with phase as coded.
So I generated 4Hz @ 5 Fs and 1 Hz @ 5 Fs and checked phase

KlausST

Super Moderator
Staff member
Hi,

"phase" is a measure from one signal to another, and both need to have the same frequency.
Phase is not an absoulte measure.
Even in mathematics when we say V_ac = amplitude x sin(w t)
t is a victive point of time when the signal(math) starts.

And in your case I see two independent frequencies. (unless they are dreived from the same frequency source):
* the sampling frequency
* and the signal frequency
As soon as they are independent .. the will drift with respect to each other. which makes the value of a phase angle invalid.

An example:
4Hz signal with at 30 Hz sampling frequency.
in a simlator you can start both at exactly the same time, and you can ste the frequency with zero error.
the 4Hz signal starts at phi = 0 and the sampling frequency starts a phi = 0.
You may refer to this idealistic scenario: with non realistic conditions.

Now we use the same example with the same idealistic frequencies. Just the first ADC sample is neglected.
Again: both signals are not modified. You see the same signals but 33ms later.
* the sampling signal still is at 0° (indeed 360°, but in a circle we just have 0° to 360°)
* but the the 4Hz signal now is at 12°

So we don´t only have the
* signal frequency
* sampling frequency
* (even if they start with 0° at idealistically the same time)
* digital data offset

Indeed I find it difficult to talk about "phase" between two different frequencies.

Klaus

kaz1

Full Member level 2
Hi,

"phase" is a measure from one signal to another, and both need to have the same frequency.
Phase is not an absoulte measure.
Even in mathematics when we say V_ac = amplitude x sin(w t)
t is a victive point of time when the signal(math) starts.

And in your case I see two independent frequencies. (unless they are dreived from the same frequency source):
* the sampling frequency
* and the signal frequency
As soon as they are independent .. the will drift with respect to each other. which makes the value of a phase angle invalid.

An example:
4Hz signal with at 30 Hz sampling frequency.
in a simlator you can start both at exactly the same time, and you can ste the frequency with zero error.
the 4Hz signal starts at phi = 0 and the sampling frequency starts a phi = 0.
You may refer to this idealistic scenario: with non realistic conditions.

Now we use the same example with the same idealistic frequencies. Just the first ADC sample is neglected.
Again: both signals are not modified. You see the same signals but 33ms later.
* the sampling signal still is at 0° (indeed 360°, but in a circle we just have 0° to 360°)
* but the the 4Hz signal now is at 12°

So we don´t only have the
* signal frequency
* sampling frequency
* (even if they start with 0° at idealistically the same time)
* digital data offset

Indeed I find it difficult to talk about "phase" between two different frequencies.

Klaus
It is not about phase of different frequencies. In my coded example it is about same frequencies as either 1 Hz @ 5 Fs or 1 Hz (as alias of 5-4=1).

KlausST

Super Moderator
Staff member
Hi,
It is not about phase of different frequencies
if it´s not about different frequencies, then it has to be about identical frequencies.

Where do you have identical frequencies. I don´t see them.

Klaus

TicTek

Newbie level 5
What I see on the waveforms is that:
4Hz @ 30 Fs, no issue of aliasing
4Hz @ 11 Fs, no issue of aliasing
4Hz @ 10 Fs, no issue of aliasing
4Hz @ 6 Fs, aliasing(alias at 2Hz)
4Hz @ 5 Fs, aliasing (alias at 1 Hz)

I took last case and the alias would be at 1Hz with phase as coded.
So I generated 4Hz @ 5 Fs and 1 Hz @ 5 Fs and checked phase
I understood that. What I am trying to see is how the last 2 case introduce phase aliasing by itself. You did write the -PI/4 in the code, is t phase aliasing happening automatically in case 4 and f?
--- Updated ---

Hi,

"phase" is a measure from one signal to another, and both need to have the same frequency.
Phase is not an absoulte measure.
Even in mathematics when we say V_ac = amplitude x sin(w t)
t is a victive point of time when the signal(math) starts.

And in your case I see two independent frequencies. (unless they are dreived from the same frequency source):
* the sampling frequency
* and the signal frequency
As soon as they are independent .. the will drift with respect to each other. which makes the value of a phase angle invalid.

An example:
4Hz signal with at 30 Hz sampling frequency.
in a simlator you can start both at exactly the same time, and you can ste the frequency with zero error.
the 4Hz signal starts at phi = 0 and the sampling frequency starts a phi = 0.
You may refer to this idealistic scenario: with non realistic conditions.

Now we use the same example with the same idealistic frequencies. Just the first ADC sample is neglected.
Again: both signals are not modified. You see the same signals but 33ms later.
* the sampling signal still is at 0° (indeed 360°, but in a circle we just have 0° to 360°)
* but the the 4Hz signal now is at 12°

So we don´t only have the
* signal frequency
* sampling frequency
* (even if they start with 0° at idealistically the same time)
* digital data offset

Indeed I find it difficult to talk about "phase" between two different frequencies.

Klaus
what I am trying to see by simulating is the phase aliasing due to the lower frequency when Fs/2<f<Fs as stated in the article. That means I have first simulated the original signal with Fs1=30,f=4,Ph1=Pi/4, so this is my signal reference.
I created a second signal where I want to compare it to with Fs2=6,f=4H whith fa=2 . because Fs/2<f<Fs. this leads to have a ph2=-ph1.

Last edited:

KlausST

Super Moderator
Staff member
Hi,

this leads to have a ph2=-ph1.
Yes, in the example. But in reality you will see different phases.

While one can clearly determine the alias frequency...
I say one can not clearly determine the alias frequency´s phase.

Klaus

kaz1

Full Member level 2
I understood that. What I am trying to see is how the last 2 case introduce phase aliasing by itself. You did write the -PI/4 in the code, is t phase aliasing happening automatically in case 4 and f?
--- Updated ---
Let us try understand what we are after. Your top waveforms say:

4Hz @ -pi/4 phase, at Fs = 30Hz looks like 4Hz @ phase of -pi/4
4Hz @ -pi/4 phase, at Fs = 11Hz looks like 4Hz @ phase of -pi/4
4Hz @ -pi/4 phase, at Fs = 10Hz looks like 4Hz @ phase of -pi/4

Can you explain above strange wording. 4Hz @ Fs looks like 4Hz @ Fs.

These last two wordings make some sense:
4Hz @ -pi/4 phase, at fs = 6Hz looks like 2Hz @ phase of +pi/4
4Hz @ -pi/4 phase, at fs = 5Hz looks like 1Hz @ phase of +pi/4

Though based on KLausST "ambiguity of aliased phase theory" we better give up this thread.

You have also added two red arrowed lines?? what do they mean?

TicTek

Newbie level 5
Thank you both. Those two arrows are explained as that whenever we have a frequency d which is between certain value, with the violation of Nyquist criteria, we get a phase aliasing. my objective was to simulate that in Matlab for better understanding