Signal Processing Output LTI System

4 ビュー (過去 30 日間)
Jorge Sola
Jorge Sola 2020 年 8 月 31 日
回答済み: Haseeb Abbas 2022 年 4 月 22 日
Hi! I'm triying to calculate the output signal of a LTI system. I have a gaussian pulse as an input and the transfer function in frequency domain of a filter. I want to compare both outputs by using the convolution of the input signal and impulse response (time domain solution) and using the product of the input spectrum and the transfer function (frequency domain solution). But the problem is that I get differents solutions. Any help??
Main code
%% Ultra short pulse at the input
c=299792458; %light speed
width=100e-15; %pulse width
T = width/(2*(sqrt(log(2)))); %period
lambda0=1550e-9; %carrier frequency
w0=(2*pi*c)/lambda0;
tstep=T/100; % time step (s)
Fs=1/tstep %sampling frequency
t1=-2*T+tstep:tstep:2*T; %axis time
tconv=-2*T:tstep/3.75:2*T+tstep/3.75;%convolution axis time
L=length(t1);
A1=sin(w0*t1).*exp(-2*log(2)*t1.^2/(width/2).^2); % Gaussian intensity modulated sine pulse
A2=sin(w0*tconv).*exp(-2*log(2).*tconv.^2/(width/2).^2);%
y1=exp(-2*log(2)*t1.^2/(width/2).^2); % Gaussian intensity envelope
figure(1)
plot(t1,A1,'r','linewidth',1)
hold on
plot(t1,y1,'b','linewidth',2)
xlabel('t')
ylabel('E(t)')
legend('E(t)','Envelope')
%Spectrum of the gaussian input pulse
n = 10000;
Y=fft(A1,n);
fshift = 1:1/(tstep*n):2.5e14;
lambda=c./fshift;
powershift=(abs(Y(1:3*n/20+2)./L));
figure (2) %Hertzs plot
plot(fshift,powershift);
xlim([0, 2.5e14])
xlabel('frequency(Hz)')
ylabel('Magnitude |X(f)|')
figure(3) %Lambda plot
plot(lambda,powershift);
xlim([1.2e-6, 1.8e-6])
xlabel('lambda(m)')
ylabel('Magnitude |X(f)|')
%Filter's transfer function
K=0.08;
L2=2*pi*5.7172e-06;
ng=4.18;
H12_2=-(sqrt(K^2.*exp(-j*2*pi*L2*ng./lambda))./(1-(1-K).*exp(-j*2*pi*L2*ng./lambda))); %Transfer function
output_frequency_abs=abs(H12_2).*powershift;
output_frequency=H12_2.*Y(1:3*n/20+2);
figure(4)
subplot(1,2,1)
plot(lambda,output_frequency_abs);
xlim([1.2e-6, 1.8e-6])
xlabel('lambda(m)')
ylabel('Magnitude |X(f)|')
% Impulse Response time domain
Impulse_Response_time=(ifft((H12_2),L));
figure (5)
plot(real(Impulse_Response_time));
%Output time domain
output_time=ifft(output_frequency);
figure(6)
plot(real(output_time));
Convolution=conv(A1,Impulse_Response_time,'full');
output_freq_2=fft(Convolution,n);
powershift_2=(abs(output_freq_2(1:3*n/20+2)./L));
figure(4)
subplot(1,2,2)
plot(lambda,powershift_2);
xlim([1.2e-6, 1.8e-6])
xlabel('lambda(m)')
ylabel('Magnitude |X(f)|')
figure(7)
plot(real(Convolution));

回答 (1 件)

Haseeb  Abbas
Haseeb Abbas 2022 年 4 月 22 日
%% Ultra short pulse at the input
c=299792458; %light speed
width=100e-15; %pulse width
T = width/(2*(sqrt(log(2)))); %period
lambda0=1550e-9; %carrier frequency
w0=(2*pi*c)/lambda0;
tstep=T/100; % time step (s)
Fs=1/tstep %sampling frequency
t1=-2*T+tstep:tstep:2*T; %axis time
tconv=-2*T:tstep/3.75:2*T+tstep/3.75;%convolution axis time
L=length(t1);
A1=sin(w0*t1).*exp(-2*log(2)*t1.^2/(width/2).^2); % Gaussian intensity modulated sine pulse
A2=sin(w0*tconv).*exp(-2*log(2).*tconv.^2/(width/2).^2);%
y1=exp(-2*log(2)*t1.^2/(width/2).^2); % Gaussian intensity envelope
figure(1)
plot(t1,A1,'r','linewidth',1)
hold on
plot(t1,y1,'b','linewidth',2)
xlabel('t')
ylabel('E(t)')
legend('E(t)','Envelope')
%Spectrum of the gaussian input pulse
n = 10000;
Y=fft(A1,n);
fshift = 1:1/(tstep*n):2.5e14;
lambda=c./fshift;
powershift=(abs(Y(1:3*n/20+2)./L));
figure (2) %Hertzs plot
plot(fshift,powershift);
xlim([0, 2.5e14])
xlabel('frequency(Hz)')
ylabel('Magnitude |X(f)|')
figure(3) %Lambda plot
plot(lambda,powershift);
xlim([1.2e-6, 1.8e-6])
xlabel('lambda(m)')
ylabel('Magnitude |X(f)|')
%Filter's transfer function
K=0.08;
L2=2*pi*5.7172e-06;
ng=4.18;
H12_2=-(sqrt(K^2.*exp(-j*2*pi*L2*ng./lambda))./(1-(1-K).*exp(-j*2*pi*L2*ng./lambda))); %Transfer function
output_frequency_abs=abs(H12_2).*powershift;
output_frequency=H12_2.*Y(1:3*n/20+2);
figure(4)
subplot(1,2,1)
plot(lambda,output_frequency_abs);
xlim([1.2e-6, 1.8e-6])
xlabel('lambda(m)')
ylabel('Magnitude |X(f)|')
% Impulse Response time domain
Impulse_Response_time=(ifft((H12_2),L));
figure (5)
plot(real(Impulse_Response_time));
%Output time domain
output_time=ifft(output_frequency);
figure(6)
plot(real(output_time));
Convolution=conv(A1,Impulse_Response_time,'full');
output_freq_2=fft(Convolution,n);
powershift_2=(abs(output_freq_2(1:3*n/20+2)./L));
figure(4)
subplot(1,2,2)
plot(lambda,powershift_2);
xlim([1.2e-6, 1.8e-6])
xlabel('lambda(m)')
ylabel('Magnitude |X(f)|')
figure(7)
plot(real(Convolution));

カテゴリ

Help Center および File ExchangeSpectral Measurements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by