MATLAB Fourier Transform
Note finished code Under construction.
clc
clear
M=100;
x0=0;
x00=1;
dx=(x00-x0)/M;
x(1)=x0;
k=1;
for ii=1:M;
x(ii+1)=x(ii)+dx;
f(ii)=1;
end
% eix=cosx-isinx
for ii=2:2:M-1;
F(ii)=f(ii)*(cos(x(ii)*k*2*pi)-i*sin(x(ii)*k*2*pi));
F(ii+1)=f(ii+1)*(cos(x(ii+1)*k*2*pi)-i*sin(x(ii+1)*k*2*pi))
FF(ii)=((F(ii)+F(ii+1))/2)*(x(ii+1)-x(ii))
end
Area=sum(FF)/(M-2)
% plot(x(1:M),F(1:M))
% grid on
% y=fft(f(1:M))
% hold on
% plot(x(1:M),y(1:M),'r*')
clear
M=100;
x0=0;
x00=1;
dx=(x00-x0)/M;
x(1)=x0;
k=1;
for ii=1:M;
x(ii+1)=x(ii)+dx;
f(ii)=1;
end
% eix=cosx-isinx
for ii=2:2:M-1;
F(ii)=f(ii)*(cos(x(ii)*k*2*pi)-i*sin(x(ii)*k*2*pi));
F(ii+1)=f(ii+1)*(cos(x(ii+1)*k*2*pi)-i*sin(x(ii+1)*k*2*pi))
FF(ii)=((F(ii)+F(ii+1))/2)*(x(ii+1)-x(ii))
end
Area=sum(FF)/(M-2)
% plot(x(1:M),F(1:M))
% grid on
% y=fft(f(1:M))
% hold on
% plot(x(1:M),y(1:M),'r*')
Fourier Transform
clc
clear
M=100;
xxx0=-10;
xxxx0=10;
dx=(xxxx0-xxx0)/M;
xxx=xxx0:dx:xxxx0;
for ii=1:M;
xx(ii)=rand(1,1); %fluctuations of a random signal
x(ii)=xx(ii)*sin(xxx(ii)); %samples of a sinusoidal random signal
y(ii) = fft(x(ii)); % Fourier transform of the signal
iy(ii) = ifft(y(ii)); % inverse Fourier transform
x2(ii) = real(iy(ii)); % chop off tiny imaginary parts
yy(ii)=norm(x(ii)-x2(ii));
end
plot(xxx(1:M),x(1:M))
grid on
hold on
plot(xxx(1:M),iy(1:M),'r-')
clear
M=100;
xxx0=-10;
xxxx0=10;
dx=(xxxx0-xxx0)/M;
xxx=xxx0:dx:xxxx0;
for ii=1:M;
xx(ii)=rand(1,1); %fluctuations of a random signal
x(ii)=xx(ii)*sin(xxx(ii)); %samples of a sinusoidal random signal
y(ii) = fft(x(ii)); % Fourier transform of the signal
iy(ii) = ifft(y(ii)); % inverse Fourier transform
x2(ii) = real(iy(ii)); % chop off tiny imaginary parts
yy(ii)=norm(x(ii)-x2(ii));
end
plot(xxx(1:M),x(1:M))
grid on
hold on
plot(xxx(1:M),iy(1:M),'r-')
Inverse Fourier Transform
Under construction.
Waveform and Amplitude Spectrum
Under construction.
Filtering Noise from Signals
Under construction.
Unless otherwise noted, all content on this site is @Copyright by Ahmed Al Makky 2012-2014 - http://cfd2012.com