0

as you can see in the last few lines below, I'm trying to store my function on multiple variables because it gets rather ugly. However, doing this yields the error shown below.

A fix for this would be to manually substitute k and kp, but this is precisely what I'm trying to avoid. Any help would be appreciated. thanks!

clc
clear

hbar = 1.055e-34;
mo = 9.1095e-31;
q = 1.602e-19;
kb=1.38065e-23;
T=298;
Ef = -0.1*q; % -100meV in units Joules
V0 = 1*q;
L = 1e-9;



k = @(E) (2*mo*E/hbar.^2)^.5;
kp = @(E) (2*mo*(V0-E)/hbar.^2)^.5;
fun = @(E) (exp(-2*kp*L) .* ((16*k.^2 .* kp.^2) ./ ((k.^2 + kp.^2).^2))) .* exp(-E./(kb*T));

Q = integral(fun,0,inf);

Error below

Undefined operator '*' for input arguments of type 'function_handle'.

Error in @(E)(exp(-2*kp*L).*((16*k.^2.*kp.^2)./((k.^2+kp.^2).^2))).*exp(-E./(kb*T))


Error in integralCalc/iterateScalarValued (line 314)
                fx = FUN(t);

Error in integralCalc/vadapt (line 132)
            [q,errbnd] = iterateScalarValued(u,tinterval,pathlen);

Error in integralCalc (line 83)
        [q,errbnd] = vadapt(@AToInfInvTransform,interval);

Error in integral (line 88)
Q = integralCalc(fun,a,b,opstruct);

Error in PS3_2 (line 17)
Q = integral(fun,0,inf);
RRR
  • 69
  • 6

1 Answers1

0

Use this here

k = @(E) (2.*mo.*E./hbar.^2).^.5;
kp = @(E) (2.*mo.*(V0-E)./hbar.^2).^.5;
fun = @(E) (exp(-2*kp(E)*L).*((16*k(E).^2.*kp(E).^2)./((k(E).^2+kp(E).^2).^2))).*exp(-E./(kb*T));
Q = integral(fun,0,inf);

I think you need to pass the argument E, then are you sure kb*T is correct? Maybe kp(E)*T? Then, you forgot the . is the sqrt for k and kp, or if it isn't a sqrt then the dot is on the wrong side of the power symbol.

rst
  • 2,510
  • 4
  • 21
  • 47