Reply by arkkimede April 9, 20092009-04-09
To respect the amplitude of the signal, you have to use:
for a signal NOT PERIODIC and simmetical time domain (-T/2 , T/2)

fftshift(fft(fftshift()))*dt
and for a asymmetric time domain
fftshift(fft())*dt

and the inverse:

ifftshift(ifft(ifftshift()))*fs
or
ifftshift(ifft(i))*fs

where dt = 1/fs and fs is the sampling frequency.

For a PERIODIC signal the formula become:
fftshift(fft(fftshift()))/Np
ifftshift(ifft(ifftshift()))*fs

where Np is the total number of points.

I hope this help
By
Daniele

On Tue, Apr 7, 2009 at 6:15 PM, mainraghav wrote:
> Hi everbody.I have a doubt.I am doing a problem of filtering(fir)
> in which we have to acquire our carrier precisely ..For that we have to do
> the decimation, filtering(LPF) and down conversions(it is areal time
> application).TO check the frequency I have to do fft at each stage ..NOw the
> doubt comes is every time I do fft at each stage, the amlitude of fft peak
> decreases and it becomes very low at the last stage ...WHAT CAN BE THE
> REASON?? The code is shown below..
>
> clc;
> close all;
> clear all;
> fs43200;
> fcE5e3;
> no_samp=0:10000;
> fb$00;
> %acq_rang^3
> %acq better=3/4/5Hz;
>
> x=(2*pi*fc*no_samp/fs);
> y=sin(x);
> figure;
> plot(abs(fft(y,8192)));
> %%%%%%%%%%%%%%%
> %mixing
> %%%%%%%%%%%%%%%%%%%%
> flo1@0e3;
> fl_wav1=sin(2*pi*flo1*no_samp/fs);
> figure;
> plot(abs(fft(fl_wav1,8192)));
>
> fl_wav2=cos(2*pi*flo1*no_samp/fs);
>
> mx1=y.*fl_wav1;
> figure;
> plot(abs(fft(mx1,8192)));
>
> mx2=y.*fl_wav2;
> figure;
> plot(abs(fft(mx2,8192)));
>
> [n1,fo1,mo1,w1] = remezord( [0 60000], [1 0], [0.01 0.1], fs );
> b1 = remez(n1,fo1,mo1,w1);
>
> op1=conv(mx1,b1);
>
> b2=hilbert(b1);
>
> op2=conv(mx2,b2);
> %%%%%%%%%%%%%%%%
> %added signal
> %%%%%%%%%%%%%%%%%
> adop=op1+op2;
> figure;
> plot(abs(fft(adop,8192)));
>
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
> %decimate
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>
> decadimate(adop,4);
> fs1=fs/4;
>
> %%%%%%%%%%%%%%%%%%%%%%%%
> %LPF
> %%%%%%%%%%%%%%%%%%%%%%%
>
> [n3,fo3,mo3,w3] = remezord( [0 65000], [1 0], [0.01 0.1], fs1 );
> b3 = remez(n3,fo3,mo3,w3);
>
> flop=conv(decad,b3);
> figure;
> plot(abs(fft(flop,8192)));
>
> %%%%%%%%%%%%%%%
> %squaring
> %%%%%%%%%%%%%
>
> sqop=flop.*flop;
> figure;
> plot(abs(fft(sqop,8192)));
>
> %%%%%%%%%%%%%%%%%%%
> %BPF
> %%%%%%%%%%%%%%%%%%
> [n4,fo4,mo4,w4] = remezord( [70000 90000 130000 150000], [0 1 0], [0.1 0.01
> 0.1], fs1 );
> b4 = remez(n4,fo4,mo4,w4);
>
> bpop=conv(sqop,b4);
> figure;
> plot(abs(fft(bpop,8192)));
> %%%%%%%%%%%%%
> %down conversion
> %%%%%%%%%%%%%%
>
> flo25e3;
> flo2_wav=sin(2*pi*flo2*no_samp/fs1);
> i=1;
> for j=0:2500;
> mxop(i)=bpop(i).*flo2_wav(i);
> i=i+1;
> end
> figure;
> plot(abs(fft(mxop,8192)));
>
> %%%%%%%%%%%%%%%%%%
> %LPF
> %%%%%%%%%%%%%%
>
> [n6,fo6,mo6,w6] = remezord( [0 10000], [1 0], [0.01 0.1], fs1 );
> b6 = remez(n6,fo6,mo6,w6);
> lpfop=conv(mxop,b6);
> %%%%%%%%%%%%%
> %decimation
> %%%%%%%%%%%
>
> decimate(lpfop,14);
> fs2=fs1/14;
> figure;
> plot(abs(fft(dec,8192)));
>
> %%%%%%%%%%%%%%%%%%%%%%
> %LPF
> %%%%%%%%%%%%%%%%%%%%%
> [n5,fo5,mo5,w5] = remezord( [0 6000], [1 0], [0.01 0.1], fs2 );
> b5 = remez(n5,fo5,mo5,w5);
>
> output=conv(dec,b5);
> figure;
> plot(abs(fft(dec,8192)));
Reply by mainraghav April 8, 20092009-04-08
Hi everbody.I have a doubt.I am doing a problem of filtering(fir)
in which we have to acquire our carrier precisely ..For that we have to do the decimation, filtering(LPF) and down conversions(it is areal time application).TO check the frequency I have to do fft at each stage ..NOw the doubt comes is every time I do fft at each stage, the amlitude of fft peak decreases and it becomes very low at the last stage ...WHAT CAN BE THE REASON?? The code is shown below..
clc;
close all;
clear all;
fs43200;
fcE5e3;
no_samp=0:10000;
fb$00;
%acq_rang^3
%acq better=3/4/5Hz;

x=(2*pi*fc*no_samp/fs);
y=sin(x);
figure;
plot(abs(fft(y,8192)));
%%%%%%%%%%%%%%%
%mixing
%%%%%%%%%%%%%%%%%%%%
flo1@0e3;
fl_wav1=sin(2*pi*flo1*no_samp/fs);
figure;
plot(abs(fft(fl_wav1,8192)));

fl_wav2=cos(2*pi*flo1*no_samp/fs);

mx1=y.*fl_wav1;
figure;
plot(abs(fft(mx1,8192)));

mx2=y.*fl_wav2;
figure;
plot(abs(fft(mx2,8192)));

[n1,fo1,mo1,w1] = remezord( [0 60000], [1 0], [0.01 0.1], fs );
b1 = remez(n1,fo1,mo1,w1);

op1=conv(mx1,b1);

b2=hilbert(b1);

op2=conv(mx2,b2);
%%%%%%%%%%%%%%%%
%added signal
%%%%%%%%%%%%%%%%%
adop=op1+op2;
figure;
plot(abs(fft(adop,8192)));

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%decimate
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

decadimate(adop,4);
fs1=fs/4;

%%%%%%%%%%%%%%%%%%%%%%%%
%LPF
%%%%%%%%%%%%%%%%%%%%%%%

[n3,fo3,mo3,w3] = remezord( [0 65000], [1 0], [0.01 0.1], fs1 );
b3 = remez(n3,fo3,mo3,w3);

flop=conv(decad,b3);
figure;
plot(abs(fft(flop,8192)));

%%%%%%%%%%%%%%%
%squaring
%%%%%%%%%%%%%

sqop=flop.*flop;
figure;
plot(abs(fft(sqop,8192)));

%%%%%%%%%%%%%%%%%%%
%BPF
%%%%%%%%%%%%%%%%%%
[n4,fo4,mo4,w4] = remezord( [70000 90000 130000 150000], [0 1 0], [0.1 0.01 0.1], fs1 );
b4 = remez(n4,fo4,mo4,w4);

bpop=conv(sqop,b4);
figure;
plot(abs(fft(bpop,8192)));
%%%%%%%%%%%%%
%down conversion
%%%%%%%%%%%%%%

flo25e3;
flo2_wav=sin(2*pi*flo2*no_samp/fs1);
i=1;
for j=0:2500;
mxop(i)=bpop(i).*flo2_wav(i);
i=i+1;
end
figure;
plot(abs(fft(mxop,8192)));

%%%%%%%%%%%%%%%%%%
%LPF
%%%%%%%%%%%%%%

[n6,fo6,mo6,w6] = remezord( [0 10000], [1 0], [0.01 0.1], fs1 );
b6 = remez(n6,fo6,mo6,w6);
lpfop=conv(mxop,b6);
%%%%%%%%%%%%%
%decimation
%%%%%%%%%%%

decimate(lpfop,14);
fs2=fs1/14;
figure;
plot(abs(fft(dec,8192)));

%%%%%%%%%%%%%%%%%%%%%%
%LPF
%%%%%%%%%%%%%%%%%%%%%
[n5,fo5,mo5,w5] = remezord( [0 6000], [1 0], [0.01 0.1], fs2 );
b5 = remez(n5,fo5,mo5,w5);

output=conv(dec,b5);
figure;
plot(abs(fft(dec,8192)));