Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
compute integral using quad

Subject: compute integral using quad

From: julien

Date: 3 Apr, 2013 01:06:14

Message: 1 of 2

Problem:
f(T) = integral_a^b F(w, T) dw
then to trace plot(T, f(T))
For that I use "quad" to approximate the integral.
But Matlab said "Warning: Infinite or %Not-a-Number function value encountered".
Thanks in advantage if you have any remarks.

function y=toltallA(w,T)
%%% Parameter
%%Begin parameter
L=2.9e-6;
v= 21.6e+3; %%waves velocities
a=0.142e-9;
N_0=6.022e+23;
A= 3*sqrt(3)*a^2*N_0/4;%%% Molar area
w_max=(2*pi*1.0e+12)*75.2933;
delta_M=3;
B_N=3.85e-25; %% Parameter of three-phonon normal
B_U=7.7e-25;%% Umklapp processes
alpha=3; %% constant
theta=1000; %%Average dbye temprature
c_d=1.0e-6;
h=6.626e-34;
hbar= h/(2*pi);%%% reduced planck constant
kB=1.38*1.0e-23;
coef=hbar^2/(4*pi*kB*v^2);
%end of my parameter
%%%
%%%
tau=1./(v/L+ (A*delta_M^2*2*pi*c_d)/(2*pi*v^2*w_max^2)*w.^4+(B_N+B_U*exp(-theta/(alpha*T)))*T^3*w.^2);%%
y= coef*v^2/T^2*tau.*w.^3.*exp(hbar*w./(kB*T))./(exp(hbar*w./(kB*T))-1).^2;

MAin Program
T=1:10:1000;
QlA=zeros(size(T));
for k=1:length(T)
QlA(k)= quad(@(Z)toltallA(Z,T(k)),1.e-20,(2*pi*1.0e+12)*75);
end


plot(T,QlA);

Subject: compute integral using quad

From: Roger Stafford

Date: 3 Apr, 2013 05:03:12

Message: 2 of 2

"julien" wrote in message <kjfva6$qkc$1@newscl01ah.mathworks.com>...
> .......
> y= coef*v^2/T^2*tau.*w.^3.*exp(hbar*w./(kB*T))./(exp(hbar*w./(kB*T))-1).^2;
> ......
- - - - - - - - -
  The exponent "hbar*w./(kB*T)" in your computation of y is exceeding 710 for T = 1 and w near its upper limit. That produces an overflow to infinity for the exponential function exp(hbar*w./(kB*T)) and you will then be dividing infinity by infinity which produces a NaN. Perhaps you can get around this by using an equivalent

 exp(-hbar*w./(kB*T))./(1-exp(-hbar*w./(kB*T))).^2

in your expression for y.

Roger Stafford

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us