From: kk KKsingh on 26 May 2010 15:28 How can i calculate the Energy of the signal in Matlab When i try to calculate for positive half i am getting Energy at right frequency ! But some thing is wrong when i do it for whole signal i am not getting at -30 and +30... N=1024; dt=.001; t=0:dt*dt*(N-1); y=sin(2*pi*30*t); e=abs(fft(y))/(N); energy=e.^2; k=1/dt/N*[-N/2:N/2-1] plot(k,e) I am not able to get where i am doing wrong ! If i do it for positive half using energy=e.^2(1:N/2)..I am getting at Energy30 Hz..but if i use for full then i am not getting at -30 and +30 but getting some where near 470.. Thanks for your help kk
From: Matt J on 26 May 2010 15:37 plot(k,fftshift(e))
From: kk KKsingh on 26 May 2010 16:07 "Matt J " <mattjacREMOVE(a)THISieee.spam> wrote in message <htjt91$1qa$1(a)fred.mathworks.com>... > > plot(k,fftshift(e)) Thanks ! I tried this before too but didnt worked ! But this time it did my fault !
From: kk KKsingh on 27 May 2010 18:15 "kk KKsingh" <akikumar1983(a)gmail.com> wrote in message <htjsok$rl6$1(a)fred.mathworks.com>... > How can i calculate the Energy of the signal in Matlab > > When i try to calculate for positive half i am getting Energy at right frequency ! But some thing is wrong when i do it for whole signal i am not getting at -30 and +30... > N=1024; > dt=.001; > t=0:dt*dt*(N-1); > y=sin(2*pi*30*t); > e=abs(fft(y))/(N); > energy=e.^2; > k=1/dt/N*[-N/2:N/2-1] > plot(k,e) > > I am not able to get where i am doing wrong ! If i do it for positive half using energy=e.^2(1:N/2)..I am getting at Energy30 Hz..but if i use for full then i am not getting at -30 and +30 but getting some where near 470.. > > Thanks for your help > > kk Is there any difference between the energy if i calculate it in time domain and in frequency domain ! Suppose my signal is x=[1 2 3 4 5 6] So its energy will be x^2... and in Frequency domain its (fft(x))^2 As, far as i know there is no change in Energy if signal in both domains!
From: Wayne King on 27 May 2010 18:39 "kk KKsingh" <akikumar1983(a)gmail.com> wrote in message <htmqt9$8u9$1(a)fred.mathworks.com>... > "kk KKsingh" <akikumar1983(a)gmail.com> wrote in message <htjsok$rl6$1(a)fred.mathworks.com>... > > How can i calculate the Energy of the signal in Matlab > > > > When i try to calculate for positive half i am getting Energy at right frequency ! But some thing is wrong when i do it for whole signal i am not getting at -30 and +30... > > N=1024; > > dt=.001; > > t=0:dt*dt*(N-1); > > y=sin(2*pi*30*t); > > e=abs(fft(y))/(N); > > energy=e.^2; > > k=1/dt/N*[-N/2:N/2-1] > > plot(k,e) > > > > I am not able to get where i am doing wrong ! If i do it for positive half using energy=e.^2(1:N/2)..I am getting at Energy30 Hz..but if i use for full then i am not getting at -30 and +30 but getting some where near 470.. > > > > Thanks for your help > > > > kk > > > Is there any difference between the energy if i calculate it in time domain and in frequency domain ! > > Suppose my signal is x=[1 2 3 4 5 6] > > So its energy will be x^2... > > and in Frequency domain > > its (fft(x))^2 > > As, far as i know there is no change in Energy if signal in both domains! Hi, it depends on how you define the Fourier transform whether it is a unitary operator or not (energy preserving). The way the DFT is defined in Matlab, it is not energy preserving: x = [1 2 3 4 5 6]; xDFT = fft(x); Note that norm(x,2) is not equal to norm(xDFT,2) But that norm(xDFT,2)/sqrt(length(x)) equals the norm of the time domain signal. Wayne
|
Next
|
Last
Pages: 1 2 Prev: Reading a delimited file Next: No method 'java.lang.System.getProperty' |