I have a data set containing x (time) and y (concentration). Is it possible to calculate nyquist frequency from this ?
From the below time series the y values are being generated by solving a system of ODE's.
The time period of cycle is 24hrs (1440 min)
time=[0:0.05:1440]; %time in minutes
Thanks
Given an evenly sampled signal sampled at a rate R samples per seconds, the Nyquist frequency can be obtained as half the sampling rate or R/2.
In your specific case, you have 1 sample every 0.05 minute, so the sampling rate is 20 samples per minutes, or ~0.333 sample per seconds (i.e. ~0.333Hz). The Nyquist frequency is thus ~0.167Hz.
Related
I have two questions that are bugging me:
Does the duration of an audio signal affect the amplitude of frequency components of that same signal? For example, I am recording the sound of a fan using a microphone. At first, I record only for 10 sec and convert the audio signal into frequency spectrum. Then, I record the same sound for 20 sec and then convert the audio signal into frequency spectrum. In both the cases, the sound of the fan is same, but does the duration of the signal affect the amplitude of frequency components in the spectrum plot?
For example, I have 2 audio signals. For the first one, I have that same fan sound recording for 10 sec and the sampling frequency is 5KHz, and for the second recording, I have that same audio signal but now the sampling frequency is changed to 15KHz. I used MATLAB to check the power for both the signals and the power for both the signals was same, however I want to know why. Formula that I used was Power=rms(signal)^2. According to me the second signal should have more power because now there are more number of samples compared to the first recording and since those extra samples would also have a random amplitude, the average shouldn't be the same as for the first one. Am I thinking it right?
Can anyone provide their thoughts? Thank You!
This answer is from: https://dsp.stackexchange.com/questions/75025/does-the-duration-of-a-signal-affect-its-frequency-components-amplitude-also
Power is energy per unit time. If you increase the duration, you increase the energy, but due to the normalization with time the power would be the same.
The DFT as given by
X[k]=∑n=0N−1x[n]e−j2πnk/N
will scale the frequency component by N as given by the summation over N samples. This can be normalized by multiplying the result by 1/N.
The frequency components of the signal levels will be the same in a normalized DFT (normalized by dividing by the total number of samples) for signal components that occupy one bin (pure tones), but the noise floor as observed may be lower by the change in sampling rate: if the noise floor is limited by quantization noise, the total quantization noise (well approximated as white noise, meaning constant across all frequencies) will be spread over a wider frequency range, so increasing the sampling rate will cause the contribution of quantization noise on a per Hz basis (noise density) to be lower. Further the duration will effect the frequency resolution in each bin in the frequency domain; for an unwindowed DFT, the equivalent noise bandwidth per bin is fs/N where fs is the sampling rate and N is the number of bins. At a given sampling rate, increasing the number of bins will increase the total duration and thus reduce the noise bandwidth per bin; causing the overall DFT noise floor as observed to decrease. (Same noise power just less measured in each bin). Windowing if done in the time domain will reduce the signal level by the coherent gain of the window, but increase the equivalent noise bandwidth such that pure tones will be reduced more than noise that is spread over multiple bins.
I want to generate a variable frequency sinusoidal signal. I am changing the frequency from 0Hz to 30Hz, but the frequency sine output increases above 30Hz during first 1 second simulation and finally after 1 second the frequency settles down to 30Hz.
Please suggest me why the frequency of the sine wave not following the frequency.
It because of simulation Sample time , It is one second.
Change the Sample time to a small number such as 0.01
It looks like you misread some parameters of chirp usage, particularly target frequency and target time.
When you work with a swept cosine sweep, target frequency will be reached at half of target time. So if you set target frequency = 30 Hz and target time = 1 s you will have 30 Hz at 0.5 s and 60 Hz at 1 s.
From Matlab documentation:
Target frequency is the instantaneous frequency of the output at half the Target time, tg/2.
Target time is the time at which the sweep reaches 2*f(tg).
I want to calculate the RMS value for a sinusoidal wave by taking only 40 samples per cycle. The sampling frequency is 2 KHz and the sine frequency is 50 Hz.
Please, can anyone give me a hint?
I created the simulink model shown in the image, using the following blocks:
Sine Wave - Simulink > Sources
RMS - Simscape > Power Systems > Specialized Technology > Control & Measurements
Mux - Simulink > Signal Routing
Scope - Simulink > Sinks
In order to configure the Sine Wave block I chose a Sample Based (discrete) Sine type with an Amplitude of 10 V and 40 Samples per period, as you requested. Since you want the sine to have a frequency of 50 Hz, the Sample time must be the period of the signal T = 1/(50 Hz) = 0.02s divided by 40, which yields 5e-4 s. The remaining parameters were left at the default values.
Then, I configured the RMS block with a Fundamental frequency of 50 Hz to match the frequency of the sine wave, and changed the Initial RMS value to 0 V. The remaining parameters were left at the default values.
Finally I simulated the model for 0.08 s (4 cycles). Since the sine wave has an amplitude of 10 V, the theoretical RMS value is the amplitude divided by the square root of 2, which yields 7.07 V. The readings obtained from the scope confirm this value (purple line).
Note how the RMS block requires to wait for one period of the signal to generate the first reading. During this period, the displayed reading is the Initial RMS value that we configured previously at 0 V.
I have sampled the 50Hz output current of an inverter with sampling frequency of 50 KHz for 1 minute. I am supposed to divide the time to 200ms packages(0.2s or 10 periods of the main signal)and do the FFT on each package. So it means that I have 10000 samples in each package (if not I zero pad or truncate ,that does not make a big difference). I am also supposed to extract the frequency spectrum up to 9 KHz. Results are ok for low frequencies but I have wrong results (the values are the half of what for high frequency). Could you help me to understand what am I doing wrong?!
I have an idea, maybe some thing like the code below is happening to my FFT. Just change SF to 10000 and look how the results will be changed !
in this code if you change the SF(sampling frequency) from 30000 to 10000,
the results for high frequncies will be distorted and disordered . why ?
SF = 30000; %sampling frequency
% signal
t = 0:1/SF:1-1/SF; % sample points
wave=15*sin(2*pi*1*t)+1*sin(2*pi*123*t)+2*sin(2*pi*203*t)+3*sin(2*pi*223*t)+4*sin(2*pi*331*t)+5*sin(2*pi*2812*t)+6*sin(2*pi*5752*t)+7*sin(2*pi*7993*t);
wavefft = fft(wave);
L=floor(size(wave,2)/2)+1; % removing the mirror side of spectrum
MagSpec = abs(wavefft(1:L))/(SF/2); %% removing the mirror side of the spectrum
and ranging the domain
plot(MagSpec);
What you are observing is aliasing.
As you can see by comparing the results using a sampling rate of 50kHz
and that of using a sampling rate of 10kHz
The sinusoidals signals whose frequency where below half the sampling rate of 10kHz (Nyquist frequency), that is the sinusoidals at 1Hz, 123Hz, 203Hz, 223Hz, 331Hz and 2812Hz are not affected. The ones at 5752Hz and 7993Hz are aliased to 4248Hz and 2007Hz respectively.
You can still perform the FFT on 200ms or 10000 samples, but the sampling rate remains the same at 50kHz. That is you would have:
SF = 50000; %sampling frequency
% signal
t = 0:1/SF:1-1/SF; % sample points
wave=15*sin(2*pi*1*t)+1*sin(2*pi*123*t)+2*sin(2*pi*203*t)+3*sin(2*pi*223*t)+4*sin(2*pi*331*t)+5*sin(2*pi*2812*t)+6*sin(2*pi*5752*t)+7*sin(2*pi*7993*t);
for the signal generation, but you would split the resulting wave signal in chunks for your processing:
for i=1:floor(length(wave)/10000)
wavefft = fft(wave(1+(i-1)*10000:i*10000))
% do somthing with the wavefft result
end
>> fft([1 4 66])
ans =
71.0000 -34.0000 +53.6936i -34.0000 -53.6936i
Can someone explain according the result above?
EDIT Well that's embarassing. I left out a factor of 2. Updated answer follows...
The Discrete Fourier Transform, which an FFT algorithm computes quickly, assumes the input data of length N is one period of a periodic signal. The period is 2*pi rad. The frequency of the output points is given by 2*n*pi/N rad/sec, where n is the index from 0 to N-1.
For your example, then, 71 is the value at 0 rad/sec, commonly called DC, -34+53.7i is the value at 2*pi/3 rad/sec, and its conjugate is the value at 4*pi/3 rad/sec. Note that by periodicity, 2*pi/3 rad/sec = -2*pi/3 rad/sec = 4*pi/3 rad/sec. So the second half of the spectrum can be regarded as the frequencies from -pi..0 or pi..2*pi.
If the data represents sampled data at a constant sampling rate, and you know that sampling rate, you can convert rad/sec to Hz. Let the sampling rate be deltaT. Its reciprocal is the sampling frequency Fs. Then the period is T = N*deltaT sec = 2*pi rad. 1/T gives the frequency resolution deltaF = Fs/N Hz. Therefore the frequency of the output points is n*Fs/N Hz.
This is a vector of complex numbers representing your signal in frequency domain.