Graphics Programs Reference
In-Depth Information
end
value = temp1 * sumnew;
end
Listing 2.10. MATLAB Function Ðfactor.mÑ
function [val] = factor(n)
% Compute the factorial of n using logarithms to avoid overflow.
format long
n = n + 9.0;
n2 = n * n;
temp = (n-1) * log(n) - n + log(sqrt(2.0 * pi * n)) ...
+ ((1.0 - (1.0/30. + (1.0/105)/n2)/n2) / 12) / n;
val = temp - log((n-1)*(n-2)*(n-3)*(n-4)*(n-5)*(n-6) ...
*(n-7)*(n-8));
return
Listing 2.11. MATLAB Program Ðfig2_7.mÑ
% This program can be used to reproduce Fig. 2.7
close all
clear all
format long
ii = 0;
for x = 0:.1:20
ii = ii+1;
val1(ii) = incomplete_gamma(x , 1);
val2(ii) = incomplete_gamma(x , 3);
val = incomplete_gamma(x , 6);
val3(ii) = val;
val = incomplete_gamma(x , 10);
val4(ii) = val;
end
xx = 0:.1:20;
plot(xx,val1,'k',xx,val2,'k:',xx,val3,'k--',xx,val4,'k-.')
legend('N = 1','N = 3','N = 6','N = 10')
xlabel('x')
ylabel('Incomplete Gamma function (x,N)')
grid
Listing 2.12. MATLAB Function Ðthreshold.mÑ
function [pfa, vt] = threshold (nfa, np)
% This function calculates the threshold value from nfa and np.
% The Newton-Raphson recursive formula is used (Eqs. (2-63) through (2-66))
Search WWH ::




Custom Search