I am getting this error (not enough input argument)

3 views (last 30 days)
I am trying to execute this codes, but I am getting error. Someone should kindly help. The error is pasted below the code
function [q_02, q_02_BB] = NFRHT_GaSb(d, T_0, T_2,Plot_On_or_Off)
set(0,'defaultaxesfontsize',20);
set(0,'defaulttextfontsize',20);
set(0,'defaultaxeslinewidth',2);
set(0,'defaultlinelinewidth',3);
set(0,'defaultlinemarkersize',10);
set(0,'DefaultFigureWindowStyle','docked');
set(0,'DefaultFigurePosition', [0 918 1120 840]);
color_1 = [0.7411, 0, 0.1490];
color_2 = [0.9412, 0.2314, 0.1255];
color_3 = [0.9922, 0.5529, 0.2353];
color_4 = [0.9961, 0.8, 0.3608];
color_5 = [1, 1.0, 0.3980];
% Constants
c = 2.99792458E8 ; % speed of light [m/s]
h_bar = 1.054E-34 ; % Planck constant [J*s]
k_B = 1.381E-23 ; % Boltzmann constant [J/K]
h_div_k = h_bar/k_B ; % h_bar divided by k_B [s*K]
% Set grid size and bandgap energy frequency
N_w = 2000 ; % number of points in frequency span
N_k = 5000 ; % number of points in wavevector span
% Sean's Frequency and k_r bounds
w_min = 5E12;
if T_0 > 999
w_max = 2e15;
else
w_max = 1e15;
end
%[w,k_r] = ndgrid( [(linspace(w_min,4E3,100)) , linspace(4E3,5E3,1800), linspace(5E3, w_max,100)] , (linspace(0,10000E6,N_k)) );
[w,k_r] = ndgrid( (linspace(w_min,w_max,N_w)) , (linspace(0,10000E6,N_k)) );
% Calculate dielectric functions
% Vacuum
eps_vac = 1 + 0.*w ;
% Graphene-Al203 Metamaterialeps_dielectric = 2*ones(N_w,N_k)+.00001*1i;
eps_dielectric = 4*ones(N_w,N_k)+.00001*1i;
% GaSb Interpolation function
e_GaSb = dlmread('e_GaSb.txt');
w_Ge = e_GaSb(:,1);
e_GaSb = e_GaSb(:,2) + 1i*e_GaSb(:,3);
e_GaSb_interp = interp1(w_Ge, e_GaSb, w);
% W Interpolation function
e_W = dlmread('e_W.txt');
w_W = e_W(:,1);
e_W = e_W(:,2) + 1i*e_W(:,3);
e_W_interp = interp1(w_W, e_W, w, 'linear', 'extrap');
% Define dielectric function of each plate
eps_0 = e_GaSb_interp;
eps_1 = eps_vac;
eps_2 = e_GaSb_interp;
% Calculate wavevector magnitudes
k_v = w/c ; % wavevector in vacuum [m^(-1)]
k_0 = k_v.*sqrt(eps_0) ; % wavevector in layer 0 [m^(-1)]
k_1 = k_v.*sqrt(eps_1) ; % wavevector in layer 1 [m^(-1)]
k_2 = k_v.*sqrt(eps_2) ; % wavevector in layer 2 [m^(-1)]
k_z0 = sqrt(k_0.^2 - k_r.^2) ; % z component in layer 0 [m^(-1)]
k_z1 = sqrt(k_1.^2 - k_r.^2) ; % z component in layer 1 [m^(-1)]
k_z2 = sqrt(k_2.^2 - k_r.^2) ; % z component in layer 2 [m^(-1)]
% Calculate reflectivity
r_01_TM = (eps_1.*k_z0 - eps_0.*k_z1) ./ (eps_1.*k_z0 + eps_0.*k_z1) ;
r_12_TM = (eps_2.*k_z1 - eps_1.*k_z2) ./ (eps_2.*k_z1 + eps_1.*k_z2) ;
r_01_TE = (k_z0 - k_z1) ./ (k_z0 + k_z1) ;
r_12_TE = (k_z1 - k_z2) ./ (k_z1 + k_z2) ;
% Calculate transmittivity
t_01_TM = 2*k_z0 .* eps_0.^(1/2) .* eps_1.^(1/2) ./ ( eps_1.*k_z0 + eps_0.*k_z1 ) ;
t_12_TM = 2*k_z1 .* eps_1.^(1/2) .* eps_2.^(1/2) ./ ( eps_2.*k_z1 + eps_1.*k_z2 ) ;
t_01_TE = 2*k_z0 ./ ( k_z0 + k_z1 ) ;
t_12_TE = 2*k_z1 ./ ( k_z1 + k_z2 ) ;
% Calcualte S matrices
S_12_00_TM = 0 ;
S_12_01_TM = -r_01_TM ;
S_11_00_TM = 1 ;
S_11_01_TM = t_01_TM ;
S_11_02_TM = ( S_11_01_TM .* t_12_TM .* exp(1i*k_z1*d) ) ./ ...
( 1 - S_12_01_TM .* r_12_TM .* exp(1i*2*k_z1*d) ) ;
S_12_00_TE = 0 ;
S_12_01_TE = -r_01_TE ;
S_11_00_TE = 1 ;
S_11_01_TE = t_01_TE ;
S_11_02_TE = ( S_11_01_TE .* t_12_TE .* exp(1i*k_z1 *d) ) ./ ...
( 1 - S_12_01_TE .* r_12_TE .* exp(1i*2*k_z1 *d) ) ;
% Calculate wave amplitude coefficients
% Layer 0 to layer 2
A_02_TM = S_11_02_TM ;
A_02_TE = S_11_02_TE ;
% Define depth into layers at which flux will be evaluated
t_C2 = 0 ;
t_C0 = 0 ;
% Calculate Weyl components
% Layer 0 to layer 2
g_E_02_rr = (1i*k_z2) ./ (2*k_0.*k_2) .* ...
( A_02_TM.*exp(1i*k_z2*t_C2) ) ;
g_E_02_rz = (1i*k_z2.*k_r) ./ (2*k_z0.*k_0.*k_2).* ...
(-A_02_TM.*exp(1i*k_z2*t_C2) ) ;
g_E_02_tt = (1i) ./ (2*k_z0) .* ...
( A_02_TE.*exp(1i*k_z2*t_C2) ) ;
g_H_02_rt = (k_z2) ./ (2*k_z0) .* ...
( A_02_TE.*exp(1i*k_z2*t_C2) ) ;
g_H_02_tr = (k_2) ./ (2*k_0) .* ...
(-A_02_TM.*exp(1i*k_z2*t_C2) ) ;
g_H_02_tz = (k_2.*k_r) ./ (2*k_0.*k_z0) .* ...
( A_02_TM.*exp(1i*k_z2*t_C2) ) ;
GG_02_TM = 1./(2*pi^2*imag(k_z0)) .* ( g_E_02_rr.*conj(g_H_02_tr) + g_E_02_rz.*conj(g_H_02_tz) ) ;
GG_02_TE = 1./(2*pi^2*imag(k_z0)) .* (-g_E_02_tt.*conj(g_H_02_rt) ) ;
G_T_02_TM = k_v.^2 .* real( 1i * imag(eps_0) .* ( GG_02_TM ) ) ;
G_T_02_TE = k_v.^2 .* real( 1i * imag(eps_0) .* ( GG_02_TE ) ) ;
% Calculate transmission function
G_T_02 = G_T_02_TM + G_T_02_TE ; % SI units
G_NT_02 = G_T_02/max(max(G_T_02)) ; % normalized
% Calculate harmonic oscillator energies
theta_0 = h_bar*w ./ ( exp( (h_bar*w)/(k_B*T_0) ) - 1 ) ;
theta_2 = h_bar*w ./ ( exp( (h_bar*w)/(k_B*T_2) ) - 1 ) ;
% Calculate spectral heat flux and photon flux
q_w_02_int = (theta_0-theta_2) .* k_r .* G_T_02 ;
q_w_02 = ones(1,N_w) ;
w_flux = ones(1,N_w) ;
for i_w = 1:N_w
q_w_02(i_w) = simpsons(q_w_02_int(i_w,:),min(min(k_r)),max(max(k_r)),[]) ;
w_flux(i_w) = w(i_w,1) ;
end
f_w_02 = q_w_02./h_bar./w_flux ; % spectral flux [#/s]
B_w = w.^2/4/pi^2/c^2 .* (theta_0-theta_2) ;
% Calculate the total heat flux and photon flux
q_02 = simpsons(q_w_02,min(min(w)),max(max(w)),[]); % total heat flux [W/m^2]
q_02_BB = simpsons(B_w,min(min(w)),max(max(w)),[]); % total heat flux [W/m^2]
f_02 = simpsons(f_w_02,min(min(w)),max(max(w)),[]); % total photon flux [#/(m^2 s)]
if Plot_On_or_Off == 'Plot On'
figure(5)
hh = loglog(w(:,1),q_w_02,'r-',w(:,1),B_w(:,1),'k-');
xlabel('Frequency, {\omega} (rad/s)')
ylabel('Spectral energy flux (W m^{-2} (rad/s)^{-1})')
legend('q_{\omega,d = 100 nm}','q_{\omega,blackbody}')
xlim([5e12 1e15])
set(hh(1), 'color', color_3)
else if Plot_On_or_Off == 'Plot Of'
else
end
% figure(3)
% semilogy(w(:,1),f_w_02,'r-')
% xlabel('Frequency, {\omega} (rad/s)')
% ylabel('Spectral photon flux (W m^{-2} (rad/s)^{-1})')
%
% figure(4)
% plot(w(:,1),f_w_02,'r-')
% xlabel('Frequency, {\omega} (rad/s)')
% ylabel('Spectral photon flux (W m^{-2} (rad/s)^{-1})')
% figure
% contourf(k_r*1E-7,w,k_r.*G_T_02,'LineStyle','none')
% title('Integrand, k_{r} * G_{T,02}')
% xlabel('Parallel wavevector, k_r (x10^7 m^{-1})')
% ylabel('Frequency, {\omega} (rad/s)')
BB_real = (5.67e-8)*(T_0^4 - T_2^4);
BB_ratio = q_02_BB/BB_real;
ratio = q_02/q_02_BB;
end
>> NFRHT_GaSb
Not enough input arguments.
Error in NFRHT_GaSb (line 28)
if T_0 > 999
  2 Comments
Torsten
Torsten on 23 Feb 2022
You cannot just run the function NFRHT_GaSb, you must call it with senseful input arguments:
d=...;
T_0=...;
T_2=...;
Plot_On_or_Off=...;
[q_02, q_02_BB] = NFRHT_GaSb(d, T_0, T_2,Plot_On_or_Off)

Sign in to comment.

Accepted Answer

Shanmuganathan
Shanmuganathan on 24 Nov 2022
Hi Ambali,
The function you have defined in your code takes 4 arguments as input as seen below:
NFRHT_GaSb(d, T_0, T_2,Plot_On_or_Off)
Please call the function with these 4 appropriate arguments to resolve this error.
Regards,
Shanmuganathan

More Answers (0)

Community Treasure Hunt

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

Start Hunting!