calculate normalised frequency of the below plot
1 次查看(过去 30 天)
显示 更早的评论
How to calulate frequency from above graph?
convert normalised frequency(0.03) into frequncy(hz)?
how to do this?
采纳的回答
Star Strider
2019-8-12
‘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 个评论
Star Strider
2019-8-12
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
2019-8-12
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
2019-8-12
Star Strider
2019-8-12
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
2019-8-12
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
2019-8-12
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
2019-8-12
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
2019-8-13
i have simple question what is the difference between fft(your plot) and power spectrum(my plot)?
Star Strider
2019-8-13
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
2019-8-13
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
2019-8-13
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
2019-8-13
since fs =1 it shows error and in case if i change it the fs=1000 figure plot displays
Star Strider
2019-8-13
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Transforms and Spectral Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!发生错误
由于页面发生更改,无法完成操作。请重新加载页面以查看其更新后的状态。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- 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)
亚太
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)