Hello, I keep getting an error about undefined unary operators. I don't understand this error and I don't know what else I am missing.
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Craig Egan Allistair Tan
am 20 Dez. 2021
Beantwortet: Rik
am 20 Dez. 2021
V_0 = 3.845223509e-20; % Barrier strength (0.240 eV) in J
hbar = 1.054571596e-34; % Reduced Planck constant in J-s
m = 5.465629128e-32; % Effective mass of the electron in the RTD in kg (0.06*m_e)
L = 8.00000e-9; % Well width of the RTD in m (80 Angstroms)
a = 1.00000e-9; % Barrier width in m (10 Angstroms)
e = 1.602176462e-19; % Charge of an electron in C
epsilon = 9.000000e+6; % External electric field strength in V/m
x = 0:1e-22:8e-20; % All x values represent energy in J
x_eV = @(x) x/1.602176462e-19; % This is to express energy in eV
phi1_0 = @(x) ((2*sqrt(2*m))/(3*e*epsilon*hbar)).*x.^(3/2);
phi1_a = @(x) ((2*sqrt(2*m))/(3*e*epsilon*hbar)).*(x+e*epsilon*a).^(3/2);
phi1_La = @(x)((2*sqrt(2*m))/(3*e*epsilon*hbar)).*(x+e*epsilon*(L+a)).^(3/2);
phi1_L2a = @(x) ((2*sqrt(2*m))/(3*e*epsilon*hbar)).*(x+e*epsilon*(L+2*a)).^(3/2);
phi2_0 = @(x) ((2*sqrt(2*m))/(3*e*epsilon*hbar)).*(x-V_0).^(3/2);
phi2_a = @(x) ((2*sqrt(2*m))/(3*e*epsilon*hbar)).*(x-V_0+e*epsilon*a).^(3/2);
phi2_La = @(x) ((2*sqrt(2*m))/(3*e*epsilon*hbar)).*(x-V_0+e*epsilon*(L+a)).^(3/2);
phi2_L2a = @(x) ((2*sqrt(2*m))/(3*e*epsilon*hbar)).*(x+-V_0+e*epsilon*(L+2*a)).^(3/2);
alpha = @(x) (x./(x-V_0)).^(1/4);
beta = @(x) ((x+e*epsilon*a)./(x-V_0+e*epsilon*a)).^(1/4);
gamma = @(x) ((x+e*epsilon*(L+a))./(x-V_0+e*epsilon*(L+a))).^(1/4);
zeta = @(x) ((x+e*epsilon*(L+2*a))./(x-V_0+e*epsilon*(L+2*a))).^(1/4);
K = @(x) (((exp(i.*phi1_La(x)-i.*phi1_0(x)))/16).*((((alpha(x)+i.*alpha(x).^(-1)).*(beta(x).^(-1)-...
i.*beta(x)).*(gamma(x)+i.*gamma(x).^(-1)).*(zeta(x).^(-1)-i*zeta(x)).*exp(phi2_a(x)-phi2_0(x))+...
(alpha(x)-i.*alpha(x).^(-1)).*(beta(x).^(-1)+i.*beta(x)).*(gamma(x)+...
i.*gamma(x).^(-1)).*(zeta(x).^(-1)-i.*zeta(x)).*exp(-phi2_a(x)+phi2_0(x))).*exp(phi2_L2a(x)-...
phi2_La(x))+((alpha(x)+i.*alpha(x).^(-1)).*(beta(x).^(-1)-i.*beta(x)).*(gamma(x)-...
i.*gamma(x).^(-1)).*(zeta(x).^(-1)+i.*zeta(x)).*exp(phi2_a(x)-phi2_0(x))+(alpha(x)-...
i.*alpha(x).^(-1)).*(beta(x).^(-1)+i.*beta(x)).*(gamma(x)+i.*gamma(x).^(-1)).*(zeta(x).^(-1)-...
i.*zeta(x)).*exp(-phi2_a+phi2_0)).*exp(-phi2_L2a(x)+phi2_La(x))).*exp(-i.*phi1_La(x)+i.*phi1_a(x))+...
(((alpha(x)+i.*alpha(x).^(-1)).*(beta(x).^(-1)+i.*beta(x)).*(gamma(x)-...
i.*gamma(x).^(-1)).*(zeta(x).^(-1)-i.*zeta(x)).*exp(phi2_a(x)-phi2_0(x))+(alpha(x)-...
i.*alpha(x).^(-1)).*(beta(x).^(-1)-i.*beta(x)).*(gamma(x)-i.*gamma(x).^(-1)).*(zeta(x).^(-1)-...
i.*zeta(x)).*exp(-phi2_a(x)+phi2_0(x))).*exp(phi2_L2a(x)-phi2_La(x))+((alpha(x)+...
i.*alpha(x).^(-1)).*(beta(x).^(-1)-i.*beta(x)).*(gamma(x)+...
i.*gamma(x).^(-1)).*(zeta(x).^(-1)+i.*zeta(x)).*exp(phi2_a(x)-phi2_0(x))+(alpha(x)-...
i*alpha(x).^(-1)).*(beta(x).^(-1)-i.*beta(x)).*(gamma(x)+i.*gamma(x).^(-1)).*(zeta(x).^(-1)+...
i.*zeta(x)).*exp(-phi2_a(x)+phi2_0(x))).*exp(-phi2_L2a(x)+phi2_La(x))).*exp(i.*phi1_La(x)-i.*phi1_a(x)))).^(-1);
K_conj = @(x) conj(K(x));
T = @(x) K_conj(x).*K(x);
plot(x_eV(x),T(x)), xlabel('E(eV)'), ylabel('T(E)')
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/839735/image.png)
0 Kommentare
Akzeptierte Antwort
Rik
am 20 Dez. 2021
I would suggest splitting up K in smaller parts. Currently it is extremely easy to make a mistake, and it is about as hard to spot it.
Your error is probably due to something in your code where you forgot (x):
K=@(x) beta(x)-gamma;
% ^ (x) is missing there
Ate the very least this line is incorrect:
i.*zeta(x)).*exp(-phi2_a+phi2_0)).*exp(-phi2_L2a(x)+phi2_La(x))).*exp(-i.*phi1_La(x)+i.*phi1_a(x))+...
% ^ ^
0 Kommentare
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!