calculate normalised frequency of the below plot

How to calulate frequency from above graph?
convert normalised frequency(0.03) into frequncy(hz)?
how to do this?

 Akzeptierte Antwort

Star Strider
Star Strider am 12 Aug. 2019

0 Stimmen

convert normalised frequency(0.03) into frequncy(hz)?
Multiply the normalised frequency by the Nyquist frequency.
The sampling frequency is 1/(sampling interval). The Nyquist frequency is one-half of the sampling frequency.

20 Kommentare

whAT WILL THE SAMPLING INTERVAL HERE?
NQUIST FREQUENCY HERE?
You can easily calculate the sampling interval if you have a time vector ‘t’ as:
Ts = t(2)-t(1); % Sampling Tiume (Assumes Uniform Sampling)
Fs = 1/Ts; % Sampling Frequency
Fn = Fs/2; % Nyquist Frequency
You must have either the time vector or the sampling frequency already. If you do not have at l;east one of those data, all hope is lost for calculating the Nyquist frequency.
is it possible to calulate sampling freq and time from above graph?
No. Not the way it is presented. If the plot used markers to plot the individual data points (rather than lines connecting them), it might be possible to estimate the sampling frequency and sampling interval.
If you have the .fig file for the first plot, it is relatively straightforward to recover the Line objects and get the 'XData' from them, and from that the sampling interval.
If you have the .fig file for the first plot, attach it to a Comment here. If all goes well, I can probably recover the 'XData' vector from it, and compute the information you want.
i have attached .mat file
i have also attached output data i have used to plot it .txt file
The ‘fig.mat’ file has a bunch of structures in it, none of which seem to contain anything that could be plotted. What do you want me to get from this file? What particular structures should I look at?
The ‘op.txt’ file has three columns and no explanation of any of them. None of the columns appears to be a time vector. What is it?
op.txt is ouput that i get as output in a c code. i dont get time vectors out of it..
intead of normalised freq(Pi* rad/sam) i need it like frequency(Hz)
If you do not have a time vector for ‘op.txt’, then it can be anything you want. Do you know what the time units should be (e.g. weeks, hours, nanoseconds)?
in nanoseconds or seconds
Try this:
fnm2 = 'op.txt';
D2 = load(fnm2);
ts = 1:size(D2,1); % Time Units In Seconds
L = numel(ts); % Time Units In Seconds
Ts = ts(2)-ts(1); % Sampling Tiume (Assumes Uniform Sampling)
Fs = 1/Ts; % Sampling Frequency
Fn = Fs/2; % Nyquist Frequency
FTD2 = fft(D2)/L;
Fv = linspace(0, 1, fix(L/2)+1)*Fn; % Frequency Vector
Iv = 1:numel(Fv); % Index Vector
figure
subplot(2,1,1)
plot(Fv, abs(FTD2(Iv,:))*2)
grid
xlabel('Frequency (Hz)')
ylabel('Amplitude')
title('Time Units: s')
subplot(2,1,2)
plot(Fv*1E+9, abs(FTD2(Iv,:))*2)
grid
xlabel('Frequency (Hz)')
ylabel('Amplitude')
title('Time Units: ns')
Using the ‘ts’ vector as the time vector, the Fourrier transform is straightforward to calculate and plot. To use nanoseconds as the time unit, it is only necessary to multiply ‘Fv’ by for the plot, since that is the only thing that changes.
All the data are plotted, however the data for the third vector obscures the first two. You may want to plot them separately:
figure
subplot(3,1,1)
plot(Fv*1E+9, abs(FTD2(Iv,1))*2)
grid
xlabel('Frequency (Hz)')
ylabel('Amplitude')
title('Time Units: ns')
subplot(3,1,2)
plot(Fv*1E+9, abs(FTD2(Iv,2))*2)
grid
xlabel('Frequency (Hz)')
ylabel('Amplitude')
title('Time Units: ns')
subplot(3,1,3)
plot(Fv*1E+9, abs(FTD2(Iv,3))*2)
grid
xlabel('Frequency (Hz)')
ylabel('Amplitude')
title('Time Units: ns')
Experiment to get the result you want.
thank you very much for the help.
i have simple question what is the difference between fft(your plot) and power spectrum(my plot)?
As always, my pleasure.
They are essentially the same, however the fft displays the absolute value of the amplitude, and the power spectrum displays the squared absolute value of the amplitude. There may be slight differences depending on how the power spectral density is computed, since some compute it slightly differently (for example the pwelch function uses overlapping segment averaging).
can u just modify the code for power spectrum and post it?
All you need to do is to square the fft output vector using element-wise operations, for example:
figure
subplot(2,1,1)
plot(Fv, (abs(FTD2(Iv,:))*2).^2)
grid
xlabel('Frequency (Hz)')
ylabel('Amplitude')
title('Time Units: s')
Do the same for the others.
how to use pwelch in code pls post th code with pwelch?
See the documentation on pwelch.
Hi I have got Power density
but i want to sperate each plots.
as u did done it before how to do that?
code is below
rng default
fnm2 = 'op.txt ';
D2 = load(fnm2);
ts = 1:size(D2,1); % Time Units In Seconds
L = numel(ts); % Time Units In Seconds
Ts = ts(2)-ts(1); % Sampling Tiume (Assumes Uniform Sampling )
Fs = 1/Ts; % Sampling Frequency
Fn = Fs/2; % Nyquist Frequency
[pxx,f] = pwelch(D2,fs);
plot(f,10*log10(pxx))
xlabel('Frequency (Hz)')
ylabel('PSD (dB/Hz)')
since fs =1 it shows error and in case if i change it the fs=1000 figure plot displays
You need to understand the argument list order for the pwelch function.
Try this:
[pxx,f] = pwelch(D2,[],[],[],Fs);
figure
subplot(3,1,1)
plot(f, pxx(:,1))
grid
xlabel('Frequency (Hz)')
ylabel('PSD')
title('Column 1')
subplot(3,1,2)
plot(f, pxx(:,2))
grid
xlabel('Frequency (Hz)')
ylabel('PSD')
title('Column 2')
subplot(3,1,3)
plot(f, pxx(:,3))
grid
xlabel('Frequency (Hz)')
ylabel('PSD')
title('Column 3')
That worked when I ran it.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by