如何调出MATLAB内部函数的源程序?
MATLB的函数源程序都存放在MATLAB安装文件夹内的toolbox文件夹下,这些函数都是.m文件,可以用搜索文件的方法搜索函数名找到这个函数的.m文件。
也可以在MATLAB主界面内输入edit 函数名,用M-file Editor打开这个函数的源程序。
在命令窗口中输入
edit 函数名
函数名就是你要看的函数名字,这样就可以打开源文件的M文件.不过有的函数不允许编辑,也就没有办法查看了.
Statxture 源函数
% T=SATAXTURE(F,SCALE) computes six measures of texture from an
% image (region) F. Parameter SCALE is a 6-dim row vector whose
% elements multiply the 6 corresponding elements of T for scaling
% purpose. If SCALE is not provided it defaults to all 1s. The
% output T is 6-by-1 vector with the following elements:
% T(1) =Average gray level
% T(2) =Average contrast
% T(3) =Measure of uniformity
% T(4) =Third moment
% T(5) =Measure of uniformity
% T(6) =Entropy
if nargin == 1
scale(1:6) = 1;
else% Make sure it's a row vector.
scale = scale (:)';
end
% Obtain histogram and normalize it.
P = imhist(f);
P = p./numel(f);
L = length(p);
% Compute the three moments. We need the unnormalized ones
% from function statmoments. Thses are in vector mu.
[v,mu] = statmoments(p,3);
% Compute the six texture measures:
% Average gray level.
t(1) = mu(1);
% Standard deviation.
t(2) = mu(2).^0.5;