回 帖 发 新 帖 刷新版面

主题:求助:大家帮我看看一段求广义分形维数的MATLAB程序


我在网上下载了一段求广义分形维数的MATLAB程序,如下:
function [dq,rq]=fdim(q,x,trace);
% from fdim.sh
% Estimates generalised fractal dimensions of a set of points x;
% e.g. q=0 is Hausdorf, q=1 is Information, q=2 is Correlation, etc.
% v0.20 1/7/94, copyright AJ Roberts, aroberts@usq.edu.au
% Made publically available under the GNU arrangements.
%
% x(j,:) = coordinates of the jth point of a set; % should be embeded;
% q = row vector of exponents
% dq = corresponding row of qth generalised dimension
% rq = optimistic range-factor over which the dim holds
% trace = optional argument: set to 1 if you want trace prints and graphics
% otherwise omit or set to 0
%
% The following parameters may be changed---at your own risk.
rrat=2; % square of radius-ratio for covering disks.
tol=0.03; % approx error in minimisation of curve fit.

if nargin<3, trace=0; end
[n,m]=size(x);
lrat=log(rrat);
rmax=sqrt(m)*max(max(x)-min(x));
lrrmax=2*log(rmax);
if trace, disp('computing distance histogram'); end;
t0=clock;
unwarn=1;
nor=[];
for j=1:n;
rr= sum( [ zeros(n,1) (x-ones(n,1)*x(j,:) ).^2 ]' );
k=1+floor( (lrrmax-log(rr(rr>0)))/lrat );
nor(j,max(k))=0;
for l=k; nor(j,l)=nor(j,l)+1; end;
if unwarn, et=etime(clock,t0);
if (et>5)&(2*j
et=(n-j)*5/j;
disp([num2str(et) 'secs to go']);
unwarn=0;
end;
end;
end;
nor=cumsum([ones(1,n);flipud(nor')])'/n;
[j,nr]=size(nor);
lrat=lrat/2;
lrad=log(rmax)+((-nr+1):0)*lrat;
%
% fit the curves for each exponent q
% Ref: Pawelzik & Schuster, Phys Rev A 35 (1987) pp481--484.
lrad=[lrad(1)-lrat lrad lrad(nr)+lrat]'; % pad out
dq=[];
rq=[];
for qi=q,
% if trace, disp(['analysing q = ' num2str(qi)]); end;
if abs(qi-1)>sqrt(eps) ,
lc=log( sum( nor.^(qi-1) )/n )/(qi-1);
else
lc=sum( log(nor) )/n;
end;
j=find((lc<0.1*lc(1))&(lc>0.9*lc(1)));
p=[lrad(min(j)) lrad(max(j)+2) 0.5 0.5];
% p=fmins('rampdiff',p,[0 tol],[],lrad,[lc(1) lc 0]',trace);
p=fminsearch('rampdiff',p,[],lrad,[lc(1) lc 0]',trace);
di=(lc(nr)-lc(1))/(p(2)-p(1));
dq=[dq di];
rq=[rq p(2)-p(1)];
if trace,
title(['q = ' num2str(qi) ' Dq = ' num2str(di)]);
% pause(1);
end
% Dq(i)=dq;
end;
rq=exp(rq);
% end;
% END_OF_FILE
% if test 2107 -ne `wc -c <'fdim.m'`; then
% echo shar: \"'fdim.m'\" unpacked with wrong size!
% fi
% # end of 'fdim.m'
% fi
% if test -f 'hint.m' -a "${1}" != "-c" ; then
% echo shar: Will not clobber existing file \"'hint.m'\"
% else
% echo shar: Extracting \"'hint.m'\" \(345 characters\)
% sed "s/^X//" >'hint.m' <<'END_OF_FILE'


运行时出错,我搞不太明白,请大家帮我看下是怎么回事,谢谢!
错误如下:
??? Error using ==> feval
Undefined function 'rampdiff'.

Error in ==> D:\matlab6.5\toolbox\matlab\funfun\fminsearch.m
On line 125 ==> fv(:,1) = feval(funfcn,x,varargin{:});

Error in ==> D:\51622470falpha\fdim.m
On line 63 ==> p=fminsearch('rampdiff',p,[],lrad,[lc(1) lc 0]',trace);

回复列表 (共1个回复)

沙发

你没有把函数rampdiff下载下来!

我来回复

您尚未登录,请登录后再回复。点此登录或注册