現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
Number of cycles before and after FFT
5 ビュー (過去 30 日間)
古いコメントを表示
Hi.
I have the signal y1 (fig1), take its fft, do some processing on it and take ifft to take it back to time domain. What I get is fig 2. I have two questions though:
1. Why the resultant signal is less dense than the original one (with less number of cycles)? Shouldn't they be similar?
2. Why the early indices of the resultant vector (y2), at t~ 0, have much large values? This happens sometimes in my analysis.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/283758/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/283759/image.jpeg)
Thank you
Brad
2 件のコメント
dpb
2020 年 4 月 11 日
"do some processing on it and take ifft to take it back to time domain."
Well, then the result could be anything -- it all depends on what "some processing" is.
What processing you did resulted in, well, the results you got. Some other processing would produce other results.
Brad
2020 年 4 月 11 日
Thank you for your response.
It involved a few simple multiplications and divisions. Do these two signal don't necessary have to be similar?
採用された回答
Star Strider
2020 年 4 月 12 日
Brad — You requested that I answer this so I’ll do my best.
It appears to me that ‘some processing’ is essentially some sort of lowpass filter. There are fewer cycles because the higher frequencies have been filtered out. My guess is that this is the single explanation for both of your observations.
The superposition of the higher and lower frequencies (and the absence of the higher frequencies after filtering) may account for the amplitude variations.
.
21 件のコメント
Brad
2020 年 4 月 12 日
Thank you Star fpr your comment.
So you mean they are not necessarily wrong? (because those processes in freq domain have to be perfomed).
My question is do the original signal and the resultant one have to have similar number of cycles?
Star Strider
2020 年 4 月 12 日
My pleasure.
Not necessarily, no.
They will not have a similar number of cycles if the high-frequency components of the signal are removed, since lower-frequency parts of the signal spectrum will have a lower number of cycles by definition.
Brad
2020 年 4 月 12 日
編集済み: Brad
2020 年 4 月 12 日
Thank you. Regarding fft and ifft, should we use their complex values, real values or abs values?
This is my process:
y1 = fft(x); % x(t) is original signal
y2 = (y1).* R % R(f) is a polynomial fucntion (not complex)
or
y2 = real (y1).* R
or
y2 = abs (y1).* R
y3 = ifft(y2);
- Which one is correct or does it really matter?
- Like Matlab fft example, between y1 and y2, I convert the signal into single-sided spectrum (half the index and double the amplitude). Between y2 and y3, I comvert it back to two-sided spectrum to have the full cycle. Do these processes may act as filter and lead to less number of cycles?
Thank you
dpb
2020 年 4 月 12 日
- Of course it matters.
- Which is correct depends upon what one is trying to do.
- What kind of a filter R is depends entirely on the coefficients of the polynomial
- It's impossible for anybody to tell you anything definitive if you continue to respond only in generalities and no code...including the polynomial itself.
Star Strider
2020 年 4 月 12 日
Brad —
1. It depends on what ‘R’ is. It needs to be symmetrical w.r.t. the fft result, so exactly the same operation is done on the complex-conjugate parts of the vector. If it isn’t symmetrical, then the results are useless. It must be done only on the original complex fft because that’s the only way you can then correctly use the ifft function to invert it. (Also, if it is shifted using fftshift and then operated upon, it must then be shifted back to its original conformation before using ifft.)
2. It’s necessary to do the operation on the entire complex fft result, however after that, how it’s displayed is irrelevant. There is absolutely no point on doing any operation on half of the fft result (for example on only the positive frequencies), and certainly not on only the real or imaginary parts of the fft result.
dpb
2020 年 4 月 12 日
編集済み: dpb
2020 年 4 月 12 日
Mostly need to know what the signal y1 is and what it is one is trying to accomplish. Presuming the lower is the magnitude of your mysterious R with frequency, it's clearly a pretty rough approximate bandpass filter.
What its purpose is is still a mystery to us so responses are just general comments on signal processing in general.
Also I presume must have gotten this from some book or research paper??? A link to context would undoubtedly shed much light on a presently nearly opaque discussion...
Star Strider
2020 年 4 月 12 日
Brad —
The ‘symmetry’ concept is part of the fft itself, and easily seen when plotted after using the fftshift function. At matching ‘positive’ and ‘negative’ frequencies, the components of the fft are complex conjugates of each other. Symmetrical (meaning identical) operations must be performed on the positive and negative frequencies.
The signal itself can be anything and does not need to be symmetrical about any axis.
Brad
2020 年 4 月 12 日
I understand, but R function is not symmetric and you said it would be useless if it is applied to fft result?
Star Strider
2020 年 4 月 12 日
The ‘R’ function must do the same operation on the complex-conjugate parts of the fft (for example, multiplication by the same quantity, although that quantity need not be the same elsewhere on other frequency ‘pairs’). If it doesn’t, the results are useless. That is simply the nature of the fft and its inverse.
If ‘R’ is only operating currently on the positive frequencies for example, you can use one of the flip and concatenation commands to have it operate symmetrically on the both halves. That would work. Then take the ifft of that result.
Brad
2020 年 4 月 12 日
I see. Thanks for that.
1. But why do I need to apply it to negative values as well, while the fft function itself includes the negative side as the mirrored (frm f/2: end) as you explained here?
2. According to literature for my analysis, I have to multiply R function only to single-sided spectrum (not sure why though). From your explanation, I realize maybe I did it wrong?
3. So if I want to skip this flipping, I simply multiply entire fft output by R and then take ifft? This would already include the negative frequencies, right?
4. Do I need to scale the fft reult by the the lentth? There are many arguments in the forum about that? Matlab example does divide by L? what do you think? And if we do, do we need to divide (or multiply) the result of ifft by L as well?
5. Also, that example, Matlab example also works with single sided spectrum, why is that?
Thanks for your help
dpb
2020 年 4 月 12 日
編集済み: dpb
2020 年 4 月 13 日
"R function is not symmetric and ...useless if it is applied to fft result?"
You must make it symmetric around the zero frequency point and then apply to both negative and positive frequencies...
Or, if you're careful to put things in the right place/order, you can operation on the positive frequency side and then flip that result around the zero frequency. BUT the symmetry point is in the middle of the complex vector and goes both ways from there so have to be careful...also NB: the DC and Fmax components are unique in the vector -- there's only one of each of them so they aren't in the symmetry game...
Using the example at doc fft because had it still in memory owing to recent other Q? (with the exception that subtracted mean so DC component is almost identically zero as that had to do with other poster's problem), the figure for real()/imag() components looks like
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/283984/image.jpeg)
and since L=1500, the vertical line is at point 751 (L/2+1).
>> arrayfun(@(i) fprintf('%d %12.5e + %12.5e\n',i,real(Y(i)),imag(Y(i))),L/2+1+[-5:5])
746 2.42442e-07 + 2.41797e-08
747 -7.05677e-09 + 1.68338e-08
748 1.43380e-07 + 5.22938e-08
749 -4.92976e-08 + 4.09230e-08
750 8.34723e-08 + 3.18481e-08
751 -1.14062e-07 + 0.00000e+00
752 8.34723e-08 + -3.18481e-08
753 -4.92976e-08 + -4.09230e-08
754 1.43380e-07 + -5.22938e-08
755 -7.05677e-09 + -1.68338e-08
756 2.42442e-07 + -2.41797e-08
>>
shows symmetry around the midpoint, while the two special components are:
Y(1)
ans =
1.2904e-20
>> Y(end)
ans =
-2.3242e-08 + 1.3694e-05i
>>
Where the DC is real (0 imaginary component) and the Fmax component is unique in the array.
That's why in that example computation/normalization of the one-sided PSD, P1, the factor of 2 is applied to (2:end-1).
Star Strider
2020 年 4 月 13 日
Brad —
1. Because of the symmetry issue that I already explained.
2. I’m not saying that you did it wrong, however there definitely appears to be something wrong somewhere. (You would not be the first the discover that it is not always possible to reproduce the results of published papers.)
3. If ‘R’ is already symmetrical (so that the flipping is not necessary) yes.
4. Dividing by the length (of the original signal, not the length of a zero-padded fft) is necessary to normalise it. Again, that’s how the Fourier transform is defined.
5. The example plots the single-sided spectrum. All the calculations are done on the entire spectrum (except the multiplication by 2 so that the amplitudes are accurate, correcting for the division of energy between the two sides of the fft).
.
dpb
2020 年 4 月 13 日
It'd help a lot if Brad would post link to the paper so we could figure out what the context is...looks peculiar standing alone.
Brad
2020 年 4 月 13 日
Thanks guys,
What if I do it the other way round, i.e, making R symmetric:
R2 = R(1:end-1);
R3 = cat(1,R2,flip(R2));
and then multiply the whole fft result by it.
1. Is that right?
2. I am not sure though whether I should divide R3 by 2?
3. If I do this, my final ifft result would slightly different in terms of values, but final array would be complex. Is it wrong? I mean can the output of ifft be complex?
Brad
Star Strider
2020 年 4 月 13 日
1. It would seem so. Try it.
2. It depends on how it was created. I would assume not, because the initial idea apparently was to use it on half of the fft result, without otherwise scaling it. This may require a bit of experimentation.
3. I’ve never tried that, so I can’t say for sure. If ‘R’ is purely real, then the imaginary parts of the ifft result, if present at all, should be vanishingly small with respect to the magnitudes of the real parts. If so, you can ignore them and attribute their presence to floating-point calculation approximations.
dpb
2020 年 4 月 13 日
"If ‘R’ is purely real, then the imaginary parts of the ifft result, should be vanishingly small with respect to the magnitudes of the real parts."
And, presuming you started with a real signal, if not then your symmetry condition has been violated...an indication of whether your step 1 was right or not.
On 2., the reason for multiply by two is magnitude is spread over both and need the doubling if take only half...part of what is confounding here is your R magnitude is also order of 10E-6 so the end magnitude is going to be scaled by that amount as well and that will show up as magnitude effect on the inverse signal.
As for the low frequency, as noted it clearly reduces magnitude 4-5X as much outside the 50-80 kHz band as in that range, the result should look as though bandpass filtered. Why so jaggedy still seems peculiar to me.
Surely wish would give some context of the application/reference...
Brad
2020 年 4 月 18 日
Star,
I accepted your answer. Thank you
Regarding the Matlab example for fft, for representation, it plots the abs values but only for the half-cycle, does that mean that we have to do that all the time? i.e, If we are interested in displaying the P-f plot, we have to plot it for half cycle (double the value) and we have to normalize it?
Thanks
Star Strider
2020 年 4 月 18 日
As always, my pleasure! Thank you.
You can plot the fft however you wish. If you plot the entire fft (after doing fftshift), the frequency axis goes from the negative of the Nyquist frequency to the positive of the Nyquist frequency, with the same number of elements as in the fft result (the reason for using linspace to create it). Depending on the intended result, this can occasionally be useful. However for most purposes, plotting only the positive half of the fft gives all the desired informaiton.
The information in the fft result is essentially duplicated in the second half (or negative frequencies after doing fftshift), so there is no real point in plotting it. The only difference is that the second half (or negative) part is the complex conjugate for the values in the first (or positive) half, a distinction that the abs function obliterates. The normalisation is done by dividing it by the length of the original signal (as opposed to the increased length of the fft if zero-padded) . The energy is equally divided between the halves of the fft result, so doubling it in half the fft result approximates the amplitude of the original signal.
Brad
2020 年 4 月 18 日
1. What is the physical or mathematical reason for fftshift?
2. Is it always necessary to use fftshift? if not, when do we have to use it?
Thanks
Star Strider
2020 年 4 月 18 日
As always, my pleasure!
1. The Fourier transform is symmetrical by definition, going from
to ∞, and fftshift allows for that symmetry convention.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/285638/image.png)
2. It is never necessary to use it. In some instances it is convenient to use it, for example to identify symmetry in the Fourier transform of a square wave:
syms f(t) t w
f(t) = 1;
F(w) = int(f*exp(-1i*w*t), t, -1, 1)
figure
fplot(F, [-10*pi 10*pi])
grid
.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Parametric Spectral Estimation についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の 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 (한국어)