plot is showing blank
이전 댓글 표시
I am not able to generate the plot. It is showing empty.
Please help me to solve the same
Thank you
clear all
clc
%% calculation of alpha angle
for i=1:2
alpha(i)= (pi*22)/180;
gamma(i)=0;
beta(i)= atan(cos(alpha(i))*sin(gamma(i))./(1+sin(alpha(i))*sin(gamma(i))));
end
%% calculation of thickness
R=0.4;
t(1)= R.*cos(alpha(1))./cot(alpha(1)+ beta(1));
t(2)= R.*cos(alpha(2))./cot(alpha(2)+ beta(2));
%%
n_1=1.49;
theta_1= asin(n_1.*sin(alpha(1)))-alpha(1);
%%
T=0.2;
H_1=0.1;
t(3)= (H_1-t(1)*(tan(alpha(1))-cot(theta_1)))./(cot(theta_1)-tan(alpha(2)));
t(4)= (t(2)*(tan(alpha(2))-cot(theta_1))+ T*(tan(alpha(1))-tan(alpha(2)))-H_1)./(tan(alpha(1))-cot(theta_1));
%%
h(1)=(T-t(1)-t(4))*tan(alpha(1));
h(2)=(T-t(3)-t(2))*tan(alpha(2));
%%
n_2=1.49;
lamda_min=0.004;
lamda_max=0.007;
phase= h(1)*(n_1 -1)./(lamda_min)+ h(2)*(n_2-1)./(lamda_min);
%%
T(1)=0.1;
e1= (sin(pi*((1-(phase/2*pi))))/(pi*((1-(phase/2*pi)))))^2;
e2= (sin(pi*(t(1)/T))/(pi*(t(1)/T)))^2;
e3= (sin(pi*(t(2)/T))/(pi*(t(2)/T)))^2;
e4= (sin(pi*(t(3)/T))/(pi*(t(3)/T)))^2;
e5= (sin(pi*(t(4)/T))/(pi*(t(4)/T)))^2;
%%
% R(j)=linspace(0,0.4,101);
syms x b(x)
f=0.025;
R=0.4;
b(x) = int(R-sqrt(R.^2-x.^2),0, f);
c(x) =sqrt((1/f)*b(x));
x =linspace(0,0.025,100);
e6= exp(((-4*pi*c(x))/lamda_min).^8);
effic= e1*e2*e3*e4*e5*e6;
fplot(effic,[0 0.025]);
% fplot(effic,x);
% efficline(0, 'k')
% syms lamda
% pide=int(e1*e2*e3*e4*e5*e6, lamda_min,lamda_max);
% fpide= (1/(lamda_max-lamda_min))*pide;
댓글 수: 2
Kundan Prasad
2021년 12월 16일
Alberto Cuadra Lara
2021년 12월 16일
편집: Alberto Cuadra Lara
2021년 12월 16일
Hello Kundan,
If you check effic, you will see that all the values are infinitive, and this is because e6 is also infinitive. You can do the verification by transforming the symbolic variable to double
double(effic)
double(e6)
This is the reason the plot is empty.
Best,
Alberto
채택된 답변
추가 답변 (2개)
Your values are all Inf. Consider checking your equations.
%% calculation of alpha angle
for i=1:2
alpha(i)= (pi*22)/180;
gamma(i)=0;
beta(i)= atan(cos(alpha(i))*sin(gamma(i))./(1+sin(alpha(i))*sin(gamma(i))));
end
%% calculation of thickness
R=0.4;
t(1)= R.*cos(alpha(1))./cot(alpha(1)+ beta(1));
t(2)= R.*cos(alpha(2))./cot(alpha(2)+ beta(2));
%%
n_1=1.49;
theta_1= asin(n_1.*sin(alpha(1)))-alpha(1);
%%
T=0.2;
H_1=0.1;
t(3)= (H_1-t(1)*(tan(alpha(1))-cot(theta_1)))./(cot(theta_1)-tan(alpha(2)));
t(4)= (t(2)*(tan(alpha(2))-cot(theta_1))+ T*(tan(alpha(1))-tan(alpha(2)))-H_1)./(tan(alpha(1))-cot(theta_1));
%%
h(1)=(T-t(1)-t(4))*tan(alpha(1));
h(2)=(T-t(3)-t(2))*tan(alpha(2));
%%
n_2=1.49;
lamda_min=0.004;
lamda_max=0.007;
phase= h(1)*(n_1 -1)./(lamda_min)+ h(2)*(n_2-1)./(lamda_min);
%%
T(1)=0.1;
e1= (sin(pi*((1-(phase/2*pi))))/(pi*((1-(phase/2*pi)))))^2;
e2= (sin(pi*(t(1)/T))/(pi*(t(1)/T)))^2;
e3= (sin(pi*(t(2)/T))/(pi*(t(2)/T)))^2;
e4= (sin(pi*(t(3)/T))/(pi*(t(3)/T)))^2;
e5= (sin(pi*(t(4)/T))/(pi*(t(4)/T)))^2;
%%
syms x b(x)
f=0.025;
R=0.4;
b(x) = int(R-sqrt(R.^2-x.^2),0, f);
c(x) =sqrt((1/f)*b(x));
x =linspace(0,0.025,100);
e6= exp(((-4*pi*c(x))/lamda_min).^8);
effic= e1*e2*e3*e4*e5*e6;
% View resulting values
double(subs(effic))
Alberto Cuadra Lara
2021년 12월 16일
Hello again Kundan,
I have to go and couldn't find the exact error. Some comments:
- Check the value of the constants and units, all in micrometers?
- H1 is less than h1. This cannot be, see Fig. 4.
- Try to include all constants at the beginning of the script. It would be easier for you to evaluate different cases.
I have tried to solve it from scratch, hope this helps.
function nu_m = matlab_answers_diffraction()
% Function that computes the final difracction efficiency from Yang 2017
% Initialization
t = zeros(1, 4);
% Constants
alpha = (pi*22)/180 * ones(1, 2);
gamma = zeros(1, 2);
beta = atan((cos(alpha) .* cos(gamma)) ./ (1 + sin(alpha) .* sin(gamma)));
n1 = 1.49; % refractive index of substrate material - top
n2 = 1.49; % refractive index of substrate material - bottom
R_T = 10; % [micrometer]
T = 100; % [micrometer]
H1 = 50; % microstructure height of double layer HDEs
lambda_min = 0.004; % [micrometer]
lambda_max = 0.007; % [micrometer]
m = 1;
f = 0.5; % [micrometer/r]
% Diffractive angle
theta = asin(n1 * sin(alpha(1))) - alpha(1);
% Distances
t([1, 3]) = compute_distances_1_3(R_T, alpha([1,2]), beta([1,2]));
t(2) = compute_distances_2(alpha, t(1), theta, H1);
t(4) = compute_distances_4(alpha, t(3), theta, H1, T);
% Effective microstructure heights
h1 = compute_heights(alpha(1), T, t(1), t(4));
h2 = compute_heights(alpha(2), T, t(2), t(3));
% Phase delay
phi = compute_phase(h1, h2, n1, n2, lambda_min);
% Diffraction efficiency with a shadowing effect
e0 = compute_c(m - phi/(2*pi));
e1 = compute_c(t(1)/T);
e2 = compute_c(t(2)/T);
e3 = compute_c(t(3)/T);
e4 = compute_c(t(4)/T);
nu_s = e0 * e1 * e2 * e3 * e4;
% RMS of the elements
dummy_fun = @(x) R_T - sqrt(R_T^2 - x.^2);
sigma = sqrt(1/f * integral(dummy_fun, 0, f));
% Final diffraction efficiency
tau = exp((-4*pi * sigma / lambda_min)^2);
nu_m = nu_s * tau^4;
end
% SUB-PASS FUNCTIONS
function value = compute_distances_1_3(R_T, alpha, beta)
% Compute distances 1 or 3 (same function)
value = (R_T * cos(alpha)) ./ cot(alpha + beta);
end
function value = compute_distances_2(alpha, t, theta, H)
% Compute distance 2
value = (H - t * (tan(alpha(1)) - cot(theta))) / (cot(theta) - tan(alpha(2)));
end
function value = compute_distances_4(alpha, t, theta, H, T)
% Compute distance 4
value = (T * (tan(alpha(1)) - tan(alpha(2))) + t * (tan(alpha(2)) - cot(theta)) - H) / (tan(alpha(1)) - cot(theta));
end
function value = compute_heights(alpha, T, t1, t2)
% Compute effective microstructure heights
value = (T - t1 - t2) * tan(alpha);
end
function value = compute_phase(h1, h2, n1, n2, lambda)
% Compute phase delay
value = h1./lambda .* (n1 - 1) + h2./lambda .* (n2 - 1);
end
function value = compute_c(x)
% Compute function c from argument x
value = (sin(pi * (x)) / (pi * (x)))^2;
end
카테고리
도움말 센터 및 File Exchange에서 Numerical Integration and Differential Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!









