Clear Filters
Clear Filters

plot is showing blank

1 view (last 30 days)
Kundan Prasad
Kundan Prasad on 16 Dec 2021
Commented: Kundan Prasad on 21 Dec 2021
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 Comments
Kundan Prasad
Kundan Prasad on 16 Dec 2021
exactly it is showing the same
Alberto Cuadra Lara
Alberto Cuadra Lara on 16 Dec 2021
Edited: Alberto Cuadra Lara on 16 Dec 2021
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

Sign in to comment.

Accepted Answer

Alberto Cuadra Lara
Alberto Cuadra Lara on 17 Dec 2021
Hello Kundan,
Some comments:
  • H1, I could not find the value in the paper. See Ref 22. and verify the value.
  • R_T is the parametric variable in case you want to reproduce Fig. 5.
  • Check per steps the values of the variables and think if it make sense each value.
  • Compare a case in which you have final results in order to check that this script works.
Best,
Alberto.
function nu_m_mean = 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
T = 100; % [micrometer]
H1 = 100; % microstructure height of double layer HDEs
lambda_min = 0.4; % [micrometer]
lambda_max = 0.7; % [micrometer]
m = 1; % diffraction order
f = 1.4; % feed rate [micrometer/r]
N = 1000;
R_T_vector = linspace(50, 400, N); % tool radius [micrometer]
% Compute Mean diffraction efficiency (PIDE)
for i = length(R_T_vector):-1:1
R_T = R_T_vector(i);
nu_m_mean(i) = compute_PIDE;
end
% Plot
plot(R_T_vector, nu_m_mean);
% NESTED FUNCTION
function nu_m_mean = compute_PIDE
% Compute Mean diffraction efficiency (PIDE)
% 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 = @(lambda) compute_phase(h1, h2, n1, n2, lambda);
% Diffraction efficiency with a shadowing effect
e0 = @(lambda) compute_c(m - phi(lambda)/(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 = @(lambda) e0(lambda) * e1 * e2 * e3 * e4;
% RMS of the elements
diamond_tool_profile = @(x) R_T - sqrt(R_T^2 - x.^2);
sigma = sqrt(1/f * integral(diamond_tool_profile, 0, f));
% Mean diffraction efficiency (PIDE)
tau = @(lambda) exp((-4*pi .* sigma ./ lambda).^2);
nu_m = @(lambda) nu_s(lambda) .* tau(lambda).^4;
nu_m_mean = 1/(lambda_max - lambda_min) * integral(nu_m, lambda_min, lambda_max);
end
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
  2 Comments
Kundan Prasad
Kundan Prasad on 17 Dec 2021
Dear Sir,
I have put the value same as mention in the refrence 22.
The attached reference pdf file is given below
file:///D:/silicon/diffractive/diffractive_3_1.pdf
Still i am getting this plot. It is totally different from actual plot.
Please have a look.
Thank you
Kundan Prasad
Kundan Prasad on 21 Dec 2021
Dear sir,
Still I am not able to plot same as given plot. I have tried by substituting with different value.
Please have a look once sir.
Thank you

Sign in to comment.

More Answers (2)

Cris LaPierre
Cris LaPierre on 16 Dec 2021
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))
ans = 1×100
Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf
  2 Comments
Kundan Prasad
Kundan Prasad on 16 Dec 2021
Dear Sir,
the equation used in the following code are attached below
Kundan Prasad
Kundan Prasad on 16 Dec 2021
Edited: Cris LaPierre on 16 Dec 2021

Sign in to comment.


Alberto Cuadra Lara
Alberto Cuadra Lara on 16 Dec 2021
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
  1 Comment
Kundan Prasad
Kundan Prasad on 17 Dec 2021
Dear Sir,
I have spotted the mistake i.e instead of lambda_min = 0.004; lambda_max = 0.007; it should be
lambda_min = 0.4; lambda_max = 0.7;
I want to plot same as fig.5 but i am not able to generate it.
Please have a look once.
Thank you

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!