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 - The Fusion of Science and Community**

Join Physics Forums Today!

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

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

Loading...

Similar Threads - Problems integrating function | Date |
---|---|

Mathematica : Integrate and a Log problem? | Mar 3, 2014 |

Problems using integral function in Matlab | Jan 11, 2013 |

Problems integrating in a for loop in Matlab | Dec 30, 2011 |

Integrate problem with undefined constant | Jul 29, 2011 |

Mathematica: Problems with integrating and plotting a function | Feb 11, 2009 |

**Physics Forums - The Fusion of Science and Community**