Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %constants
- h2=1.05e-34;
- mass=9.11e-31;
- a=5.51e-10;
- p=11;
- Emax=100*1.6e-19;
- %Figure(4) using the K in the last question
- E=linspace(0,3e-19,1000);
- alpha=sqrt(2*mass*E)/h2;
- LHS=((p/a)*sin(alpha*a)./alpha)+cos(alpha*a);
- k=acos(LHS)./a;
- %first derivative
- dy=diff(E)./diff(k);
- dy=[min(dy),dy];
- %second derivative
- dyy=diff(dy)./diff(k);
- dyy=[max(dyy),dyy];
- %effective mass
- eff_mass=(h2^2)./dyy;
- %plotting two curve the positive and the negative
- plot(k,eff_mass,-k,eff_mass);
- %part 2
- %taking the equation from the user
- sc = inputdlg('Type an expression that is a function of ‘k’:' ); % Cell Output
- k1= sc{:}; % Function String
- k_fun= str2func(['@(k)' k1]) ; % Not Vectorized (Illustration Only)
- k_funv= str2func(['@(k)' vectorize(k1)]);
- %first derivative
- first=diff(k_funv(k))./diff(k);
- first=[max(first),first];
- %second derivative
- second=diff(first)./diff(k);
- second=[min(second),second];
- %effective mass
- eff_mass2=(h2^2)./second;
- plot(k,eff_mass2,(-1)*k,eff_mass2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement