how to add a signal?
3 views (last 30 days)
Show older comments
so this is my small code on solving the nonlinear schrodinger equation , when you run the program you will get some graphs my question is how can i add a signal in which in the time domain it is constant(continuous wave in fiber optics) and will show up as a line in frequency domain?
L=1;%%length fiber
%---set simulation parameters
nt = 2^12; Tmax = 32; % FFT points and window size
step_num = 1000; % No. of z steps to
h = L/step_num; % step size in z
dtau = (2*Tmax)/nt; % step size in tau
%---tau and omega arrays
tau = (-nt/2:nt/2-1)*dtau; % temporal grid
w = (pi/Tmax)*[(0:nt/2-1) (-nt/2:-1)]; % frequency grid
beta2=0.25;
beta3=0;
D=(1i.*beta2.*0.5.*w.^2)-((1./6).*1i.*beta3.*w.^3); % dispersion operator
%%%%input pulse
A0=8;
A1=4;
A=A0*exp(-tau.^2.*0.5);
A2=1;
M=fftshift(fft(A));
%---Plot input pulse shape and spectrum
tempo =(M).*(nt*dtau)/sqrt(2*pi); % spectrum
figure;
subplot(2,1,1);
plot(tau, abs(A).^2,'--k'); hold on;
axis([-10 10 0 inf]);
xlabel('Normalized Time');
ylabel('Normalized Power');
title('Input and Output Pulse Shape and Spectrum');
subplot(2,1,2);
plot(fftshift(w)/(2*pi),abs(tempo).^2, '--k');
hold on;
axis([-10 10 0 inf]);
xlabel('Normalized Frequency');
ylabel('Spectral Power');
%%%%calculating pulse multiplied by the dispersion factor%%
gamma=0.1;% gamma=(2*pi*n2)/lamda*Aeff also Beta2=-lamdazero*D/(2*pi*c) also beta3=(lamdazero/2*pi*c)^2;{(2*lamdazero*D)+(lamdazero^2 * derivative of D)}
%temp3=temp2.*exp(h.*0);
temp2=fft(A);
temp3=temp2.*exp(D.*h.*0.5);
temp4=ifft(temp3);
%%%%%%%%%
for m=1:step_num
Nonlinear=exp(1i.*h*gamma.*A.^2).*temp4;
temp5=fft(Nonlinear);
temp6=temp5.*exp(D.*h./2);
temp4=ifft(temp6);
end
temp8=fft(temp4);
temp9=temp8.*exp(-1.*(h./2).*D);
temp10=ifft(temp9);
% final pulse
tempo=fftshift(fft(temp10)).*(nt*dtau)/sqrt(2*pi); %Final spectrum
%----Plot output pulse shape and spectrum
figure;
subplot(2,1,1);
plot(tau, abs(temp10).^2,'-k'); hold on;
axis([-20 20 0 inf]);
xlabel('Normalized Time');
ylabel('Normalized Power');
title('Input and Output Pulse Shape and Spectrum');
subplot(2,1,2);
plot(fftshift(w)/(2*pi), abs(tempo).^2, '-k');
hold on;
axis([-10 10 0 inf]);
xlabel('Normalized Frequency');
ylabel('Spectral Power');
figure
semilogy(fftshift(w)/(2*pi), abs(tempo).^2);
0 Comments
Answers (1)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!