You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
calculate normalised frequency of the below plot
1 view (last 30 days)
Show older comments
How to calulate frequency from above graph?
convert normalised frequency(0.03) into frequncy(hz)?
how to do this?
Accepted Answer
Star Strider
on 12 Aug 2019
‘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 Comments
Star Strider
on 12 Aug 2019
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.
Star Strider
on 12 Aug 2019
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.
Venkatkumar M
on 12 Aug 2019
Star Strider
on 12 Aug 2019
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?
Venkatkumar M
on 12 Aug 2019
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)
Star Strider
on 12 Aug 2019
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)?
Star Strider
on 12 Aug 2019
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.
Venkatkumar M
on 13 Aug 2019
i have simple question what is the difference between fft(your plot) and power spectrum(my plot)?
Star Strider
on 13 Aug 2019
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).
Star Strider
on 13 Aug 2019
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.
Venkatkumar M
on 13 Aug 2019
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)')
Venkatkumar M
on 13 Aug 2019
since fs =1 it shows error and in case if i change it the fs=1000 figure plot displays
Star Strider
on 13 Aug 2019
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.
More Answers (0)
See Also
Categories
Find more on Spectral Measurements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)