how to solve my problem that i write

1 次查看(过去 30 天)
asma
asma 2024-4-22
移动Dyuman Joshi 2024-4-23
I write this code and i wanne output that show me like a sinc function like picture that i attached. the other point is about my l value that i defined it, i wanne some random number between 11e-6 till 13e-6, is it true like this that i define?
tnx.
clc;
clear;
close all;
capital_lambda = 20e-6;
% define sellmier equation to obtain refractive index
lambda_sh=0.775e-6; % SH wavelength
nlithium_sh = 2.1784;
lambda_ff=1.55e-6; % FF wavelength
nlithium_ff = 2.1376;
% parameters
capital_lambda = 20e-6;
k_sh=(2*pi/lambda_sh)*nlithium_sh;
k_ff=(2*pi/lambda_ff)*nlithium_ff;
Delta_kk = k_sh-2*k_ff;
%km=2*pi/capital_lambda;
L = 1; % Length;
sigma_l = 2; % sigma_l = l*sigma_avg
N=L/(capital_lambda/2); % number of domains
l=unifrnd(11e-6,13e-6,[1,1000]); %
for i=l
f=exp(-(pi.^2) .* (sigma_l.^2)/2.*(l.^2));
Delta_k=(k_sh-2*k_ff)-pi./l;
E3= f .* (sinc((Delta_k .* L)/2)).^2 + ((1-f)/N);
end
plot(E3)
%plot(abs(fftshift(fft2(E3))))
xlabel('(Delta_k * L)/pi');
ylabel('SHG Effiency');

回答(1 个)

Hassaan
Hassaan 2024-4-22
编辑:Hassaan 2024-4-22
clc;
clear;
close all;
% Constants and parameters
lambda_sh = 0.775e-6; % SH wavelength
nlithium_sh = 2.1784;
lambda_ff = 1.55e-6; % FF wavelength
nlithium_ff = 2.1376;
L = 1; % Length in some units, assuming meters
% Wave numbers
k_sh = (2 * pi / lambda_sh) * nlithium_sh;
k_ff = (2 * pi / lambda_ff) * nlithium_ff;
% Define the range of Delta_k*L/pi to evaluate the sinc-squared function
delta_kL_over_pi = linspace(-20, 120, 10000); % For a smooth curve
Delta_k = delta_kL_over_pi * pi / L;
% Calculate the sinc-squared function
E3 = sinc(Delta_k / (2*pi)).^2;
% Plotting
figure;
semilogy(delta_kL_over_pi, E3, 'LineWidth', 2);
xlabel('\Delta k L/\pi');
ylabel('Relative Efficiency |g|^2');
title('Second Harmonic Generation Efficiency');
grid on; % Adding grid for better readability
axis tight; % Remove extra white space in the plot
-----------------------------------------------------------------------------------------------------------------------------------------------------
If you find the solution helpful and it resolves your issue, it would be greatly appreciated if you could accept the answer. Also, leaving an upvote and a comment are also wonderful ways to provide feedback.
It's important to note that the advice and code are based on limited information and meant for educational purposes. Users should verify and adapt the code to their specific needs, ensuring compatibility and adherence to ethical standards.
Professional Interests
  • Technical Services and Consulting
  • Embedded Systems | Firmware Developement | Simulations
  • Electrical and Electronics Engineering
Feel free to contact me.
  1 个评论
asma
asma 2024-4-23
移动:Dyuman Joshi 2024-4-23
why you omit f(sigma_l)? and another thing is delta_kk is a parameter that depends on k2-2*k1 , you omit this too and define delta_k_over_pi
can you explain it more
tnx alot

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Earth and Planetary Science 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by