System frequency response via fft

6 次查看(过去 30 天)
Dear all,
I am trying to determine system response with given input and output and using the system response to determine an other pair of input for a given output.
Mathematically,
System frequency response F(h)=(F(y1))/(F(x1))
where F Fourier transform
h system response
x1 top hat input
y1 system output, assumed guassian
y2 required output, top hat
x2 input to be determined
F(x2)=(F(y2))/(F(h))=(F(y2).F(x1))/(F(y1))
x2=ifft((F(y2).F(x1))/(F(y1)))
I am doing fourier transform using fft and getting strange x2 curve. Not sure what I am doing wrong.I am using the following code. Many thanks for the anticipated response.
close all
% sampling size
step_num = 100;
% x range to define the curves
x_max = 50;
x_margin = 20;
% sampling frequency
fs = step_num/(x_max+x_margin);
fx = (0:step_num-1)/step_num*fs;
% x linespace
x = linspace(0,x_max+x_margin,step_num);
% x1 top hat profile
x1 = x<=x_max; % x1 is one for Ex less than x_max and zero afterwards
x1_f = (fft(x1,step_num)/step_num);
% y1 guassian
y1 = exp(-(0.05*x).^2);
% fourier conversion
y1_f = (fft(y1,step_num)/step_num);
% y2 req: top hat profile
y2 = x<=x_max; % x1 is one for Ex less than x_max and zero afterwards
y2_f = (fft(y2,step_num)/step_num);
% determining fourier of required input
x2_f = (y2_f).*(x1_f)./(y1_f);
x2 = real(ifft(x2_f));
% curve plot
figure
plot(x,x2,'Color','green','LineWidth',2);
hold on
plot(x,x1,'Color','black','LineWidth',2);
plot(x,y1,'Color','blue','LineWidth',2);
xlabel('Radial coordinate','fontsize',12);
ylabel('Intensity','fontsize',12);
legend('Required input x2','Input x1','Output y1')
axis([0 70 0 1.1])

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Fourier Analysis and Filtering 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by