- #1
Sarah1287
- 4
- 0
Hey I'm having problems trying to integrate my function func1 in MATLAB. Really don't know where I am going wrong so would really appreciate if anyone could help. The code I'm using is below, thanks:
Function Mfile:
function [ f1 ] = func1( E, Delta, kB, Temp )
%func1: calculates integrand for eqn 1
% Detailed explanation goes here
f1=(tanh(sqrt(((E*E)+(Delta*Delta))))/(2*kB*Temp))/(2*(sqrt(((E*E)+(Delta*Delta)))));
end
Command line code:
hbar=1.054E-34; Tdebye=420; h=6.626E-34; kB1= 1.38065E-23;
fdebye=(Tdebye*kB1)/h;
Temp1=0.5;
Delta1=0;
a=hbar*fdebye;
Q=quad(@(E1)func1(E1,0,1.38065E-23,0.5),-a,a)
? Undefined function or variable 'kB'.
? Error using ==> mtimes
Inner matrix dimensions must agree.
Error in ==> func1 at 4
f1=(tanh(sqrt(((E*E)+(Delta*Delta))))/(2*kB*Temp))/(2*(sqrt(((E*E)+(Delta*Delta)))));
Error in ==> @(E1)func1(E1,0,1.38065E-23,0.5)
Error in ==> quad at 77
y = f(x, varargin{:});
Thanks
Function Mfile:
function [ f1 ] = func1( E, Delta, kB, Temp )
%func1: calculates integrand for eqn 1
% Detailed explanation goes here
f1=(tanh(sqrt(((E*E)+(Delta*Delta))))/(2*kB*Temp))/(2*(sqrt(((E*E)+(Delta*Delta)))));
end
Command line code:
hbar=1.054E-34; Tdebye=420; h=6.626E-34; kB1= 1.38065E-23;
fdebye=(Tdebye*kB1)/h;
Temp1=0.5;
Delta1=0;
a=hbar*fdebye;
Q=quad(@(E1)func1(E1,0,1.38065E-23,0.5),-a,a)
? Undefined function or variable 'kB'.
? Error using ==> mtimes
Inner matrix dimensions must agree.
Error in ==> func1 at 4
f1=(tanh(sqrt(((E*E)+(Delta*Delta))))/(2*kB*Temp))/(2*(sqrt(((E*E)+(Delta*Delta)))));
Error in ==> @(E1)func1(E1,0,1.38065E-23,0.5)
Error in ==> quad at 77
y = f(x, varargin{:});
Thanks