TicTek
Junior Member level 1
- Joined
- May 10, 2022
- Messages
- 15
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 235
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 )
Thank you.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--')
What I see on the waveforms is that: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
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).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
if it´s not about different frequencies, then it has to be about identical frequencies.It is not about phase of different frequencies
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?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
Thank you for your feedback.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
Yes, in the example. But in reality you will see different phases.this leads to have a ph2=-ph1.
Let us try understand what we are after. Your top waveforms say: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 ---
The question is not about frequency but phase.Hi,
Both frequency results are correct.
Phi can not be determined at all.
To reproduce those graphs exactly as presented, you can do this:How can I get like him where I can visualize the phase ?
close all; clear all; clc;
% Time to simulate (seconds)
Tsim = 1;
% Sinewave frequency (Hz) and initial phase (radians)
fsine = 4;
phi0 = -pi/4;
% Vector of all sample rates (Hz)
fsamp = [30, 11, 10, 6, 5];
% For each sample rate...
Nrates = length(fsamp);
for i = 1:Nrates
% Calculate number of samples to simulate
Nsamp = floor(Tsim * fsamp(i)) + 1;
% Calculate the sampled sinewave
t = (0:Nsamp-1) / fsamp(i);
x = cos(phi0 + 2*pi*fsine*t);
% Calculate the aliased frequency (Hz) and phase (radians)
fa = fsine;
pa = phi0;
while fa > fsamp(i)/2
fa = fa - fsamp(i);
pa = -pa;
end
fa = abs(fa);
% Approximate an "analog" sinewave using a high sampling frequency
fanalog = max(fsamp) * 1000;
Nanalog = floor(Tsim * fanalog) + 1;
tanalog = (0:Nanalog-1) / fanalog;
xanalog = cos(pa + 2*pi*fa*tanalog);
% Plot
subplot(Nrates,1,i);
hold on;
stem(t, x, '.b', 'LineWidth', 1);
plot(tanalog, xanalog, '--k', 'LineWidth', 1);
line([0,Tsim], [0,0], 'Color', 'r');
title([num2str(fsine) ' Hz at \pi / (' num2str(pi/phi0) ') phase, at Fs = ' num2str(fsamp(i)) ...
' Hz, looks like ' num2str(fa) ' Hz with a phase of \pi / (' num2str(pi/pa) ')']);
end
end
% Calculate the aliased frequency (Hz) and phase (radians)
fa = fsine;
pa = phi0;
while fa > fsamp(i)/2
fa = fa - fsamp(i);
pa = -pa;
end
fa = abs(fa);
% Calculate the aliased frequency (Hz) and phase (radians)
fa = fsine;
while fa > fsamp(i)/2
fa = fa - fsamp(i);
end
pa = phi0;
end
from the main code snippet. This forum has a bug that sometimes causes text to be duplicated.We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?