Hey I'm having problems trying to integrate my function func1 in MATLAB. Really dont know where Im going wrong so would really appriciate if anyone could help. The code I'm using is below, thanks:(adsbygoogle = window.adsbygoogle || []).push({});

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

**Physics Forums | Science Articles, Homework Help, Discussion**

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Problems with integrating a function in MATLAB: Inner matrix dimensions must agree

**Physics Forums | Science Articles, Homework Help, Discussion**