Why is the subs function not working?
6 views (last 30 days)
Show older comments
Hi so I have the code shown below and I want to substitute at the end in equation C the (E_F-U_0) with the parameter t. In a more simpler function it works perfectly, but for my C equation it does not work, is this an issue with the memory or is there something wrong with my coding?
clearvars -global ___
h = 4.135667662.*10.^(-15);%Planck's constant in eV.s
h_ = 6.582119514.*10.^(-16); % Reduced Planck's constant in eV.s
syms w_x % defining x-component of angular frequency
syms E_F % defining Fermi Energy
syms n % defining principal quantum number
syms E_1 % defining Energy at first energy level
syms E_2 % defining Energy at second energy level
syms V_sd % defining source-drain voltage
syms g % defining Lande g-factor
syms S % defining electron-spin
syms m_eff % defining effective mass of electron
syms g_ns % defining differential conductance for particular value of
% n and S
syms U_0 % defining electrostatic potential in the saddle point at V_sd = 0
%
syms q ; % defining variables
syms R
syms B
syms U0Vsd
syms w_y
syms w_c
syms E_Z
syms t
E_2 = ((h_)./sqrt(2)).*(((w_c.^2+w_y.^2-w_x.^2).^2 + 4.*w_x.^2*w_y.^2).^0.5+(w_c.^2+w_y.^2-w_x.^2)).^0.5;
% Energy at second energy level
E_1 = ((h_)/(2.*pi*sqrt(2))).*(((w_c.^2+w_y.^2-w_x.^2).^2 + 4.*w_x.^2*w_y.^2).^0.5-(w_c.^2+w_y.^2-w_x.^2)).^0.5;
% Energy at first energy level
E_Fn = E_F - U0Vsd - (n+0.5).*E_2;
% Energy at second energy level
mu_B = 5.7883818066.*10.^(-5); % Bohr-magneton
U0Vsd = U_0 - (0.5.*exp(1)*V_sd);%U_0 is the electrostatic potential in
%the saddle point at V_sd=0
w_y = 2.*w_x;
w_c = 0; % cyclotron frequency
E_Z = 2.*g.*mu_B.*S.*B; % Zeeman energy
m_eff = 0.067.*9.10938356.*10.^(-31); % electron's effective mass
a=(1+((1/exp(1)).*diff(U0Vsd,V_sd)));
b=exp((E_Fn+(0.5.*E_Z))/E_1).*(1+exp((E_Fn + (0.5.*E_Z))/E_1)).^(-1);
c = -(diff(U0Vsd,V_sd)).*exp((E_Fn-(exp(1).*V_sd)+ (0.5.*E_Z))/E_1);
d = (1+exp((E_Fn-(exp(1).*V_sd)+ (0.5.*E_Z))/E_1)).^(-1);
g_ns = vpa((a.*b)-(c.*d),2);
% differential conductance for particular value of n and S
B = 0; % paerpendicular component of magnetic field
g = 2.0023; % Lande g-factor
w_x = 1;
for n=1:50; % loop for calculating the values of g_ns for each
% value of n and for spin, S=-0.5
S=-0.5;
g_1(n,:)=subs(g_ns);
end
F=sum(g_1); % sum of all g_ns values for S=-0.5
for n=1:50; % loop for calculating the values of g_ns for each
% value of n and for spin, S=+0.5
S=0.5;
g_2(n,:)= subs(g_ns);
end
H=sum(g_2); % sum of all g_ns values for S=+0.5
R=0; % constant for V_sd
V_sd = R.*h_.*w_x;
G=subs(((exp(1)).^(2)/h).*(F+H));
C = G/((2.*exp(1).^(2))/h)
subs(C, E_F - U_0, t)
0 Comments
Answers (1)
Walter Roberson
on 18 Feb 2016
You have used subs(expression, expression, variable) instead of sub(expression, variable, expression) . The second parameter needs to be the name of the variable to be substituted for (or a vector or cell array of names).
If you did have reason to try to substitute for an expression with something else, you would need to use subsexpr
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!