Why is the Sum for f(t,x) Not Normalized in Matlab FFT?

In summary: Your Name]In summary, the conversation discusses the process of finding coefficients A_n for a given input signal, f(t,0), using a Fourier transform. The question at hand is how the sum for f(t,x) is normalized, and why there may be discrepancies between the theoretical solution and the numerical solution. It is suggested to normalize the Fourier transform by the total energy of the signal rather than the number of points for more accurate results.
  • #1
nickthequick
53
0
Hi,

Let's say I have an input signal

[tex] f(t,0)= \sum_n A_n cos(w_nt) [/tex]

And we know that

[tex] f(t,x)= \sum_n A_n cos(k_nx-w_nt) [/tex]

and we also have the relationship between k and w. We can find the coefficients A_n by taking a Fourier Transform of the relationship for f(0,t).

Here's my question. How is the sum for f(t,x) normalized? If this is unclear, below is an example:

I've been trying test cases to figure out what the relationship is by prescribing f(0,t) to be some easy function i.e.

[tex] f(t,0)= cos(\omega_1t) + 2cos(\omega_2t) [/tex]

Theoretically, we know that

[tex] \bar{f}(t,x)= cos(k_1x-\omega_1t) + 2cos(k_2x -\omega_2t) [/tex]

But if I did not know precisely what f(t,0) is and went through this numerically, I'd have

[tex] f^*(t,x)= \sum_n A_n cos(k_nx-\omega_nt) [/tex]

where

[tex]A_n=\frac{1}{length(f(0,t))}fft(f(t,0)) [/tex]

My problem is [tex] f^* \neq \bar{f} [/tex]. My question is, why is this the case? I think it comes down to normalizations but I'm not completely sure.

Any help would be appreciated,

Nick

PS
If you're interested, here's my code
close all;
g=10;
A= [1 .5];
tt=0:.5:2^5-.5;
omega=[1 .25];
kay=omega.^2/g;
signal = zeros(length(tt),1);
for i=1:length(tt);
signal(i,1) = sum(A.*cos(tt(i)*omega));
end
Fs= 50;
xx=1:.5:100;
yy=signal;
[YY,ff]=positiveFFT(yy,Fs); % this sets up our independent variable frequency as we want it
kk=(2*pi*ff).^2/g;

ETAETA=zeros(length(tt),length(xx));
for i =1:length(tt)
for j=1:length(xx)
ETAETA(j,i)=real(sum(YY'.*cos(kk*xx(j)-2*pi*ff*tt(i))));
end
end
figure (1)
imagesc(xx,tt,real(ETAETA));
set(gca,'YDir','normal');
caxis([-0.01 0.01])
colormap(copper);
colorbar;
xlabel('distance from wave maker'); ylabel('time');
shading('interp')
h = colorbar;
set(get(h,'YLabel'), 'String', 'SSH');
title('theoretical first order solution');
% %
% ETA3= zeros(length(xx),length(tt));
% for i=1:length(tt)
% for j=1:length(xx)
% ETA3(j,i)= sum(A.*cos(kay*xx(j)-omega*tt(i)));
% end
% end

% figure(2)
% imagesc(xx,tt,real(ETA3)');
% set(gca,'YDir','normal');
% caxis([-0.01 0.01])
% colormap(copper);
% colorbar;
% xlabel('distance from wave maker'); ylabel('time');
% shading('interp')
% h = colorbar;
% set(get(h,'YLabel'), 'String', 'SSH');
% title('theoretical first order solution');


where
positiveFFT.m is
function [X,freq]=positiveFFT(x,Fs)
N=length(x); %get the number of points
k=0:N-1; %create a vector from 0 to N-1
T=N/Fs; %get the frequency interval
freq=k/T; %create the frequency range
X=fft(x)/N; % normalize the data

%only want the first half of the FFT, since it is redundant
cutOff = ceil(N/2);

%take only the first half of the spectrum
X = X(1:cutOff);
freq = freq(1:cutOff);
 
Physics news on Phys.org
  • #2



Hi Nick,

First of all, great work on exploring this problem and writing out your code for others to see. From what I can gather, your question is related to the normalization of the Fourier transform in your code and how it relates to the theoretical solution. Let me try to break it down for you.

The normalization factor in the Fourier transform is important because it helps us to compare the amplitudes of different frequency components in a signal. In your code, you are using the function positiveFFT() to calculate the Fourier transform, and it seems like you are normalizing it by dividing by the number of points in the signal (N). This is a common approach, but it may not always give you the results you expect.

In the case of your test signal f(t,0) = cos(ω1t) + 2cos(ω2t), the Fourier transform should give you two peaks at ω1 and ω2 with amplitudes of 1 and 2 respectively. However, because you are dividing by N in your code, the amplitudes of these peaks will be scaled down. This is why you are not getting the expected result of f*(t,x) = cos(k1x - ω1t) + 2cos(k2x - ω2t).

To fix this, you can try normalizing the Fourier transform by the total energy of the signal instead of N. This can be calculated by taking the sum of the squared amplitudes of the signal before taking the Fourier transform. You can then divide the Fourier transform by this energy value to get the correct amplitudes.

I hope this helps to clarify the issue you are facing. Keep up the good work and don't hesitate to reach out if you have any further questions.
 

FAQ: Why is the Sum for f(t,x) Not Normalized in Matlab FFT?

What is the purpose of Matlab normalization using fft?

Matlab normalization using fft is used to scale the amplitude of a signal or data set to a desired range. This helps to improve the accuracy and precision of data analysis and signal processing.

How does Matlab normalization using fft work?

Matlab normalization using fft involves applying the Fast Fourier Transform (FFT) algorithm to the signal or data set, which converts the data from the time domain to the frequency domain. The data is then scaled using a normalization factor, which adjusts the amplitude to the desired range.

What are the benefits of using Matlab normalization using fft?

Some benefits of using Matlab normalization using fft include improved accuracy and precision of data analysis, easier comparison of data sets, and improved signal processing results. Normalization also helps to eliminate any bias or distortion in the data.

Can Matlab normalization using fft be used for any type of data?

Yes, Matlab normalization using fft can be used for various types of data, such as time-series data, audio signals, and images. It is a widely used method for scaling and analyzing data in various fields including engineering, science, and finance.

Are there any limitations of Matlab normalization using fft?

One limitation of Matlab normalization using fft is that it assumes the data is linear and does not take into account any non-linear relationships in the data. Additionally, normalization can sometimes amplify noise in the data, so it is important to carefully consider the data set and the desired range before applying normalization.

Similar threads

Replies
8
Views
845
Replies
1
Views
2K
Replies
16
Views
2K
Replies
1
Views
2K
Replies
16
Views
14K
Replies
9
Views
1K
Replies
3
Views
8K
Replies
1
Views
4K
Replies
1
Views
3K
Back
Top