📄 fracdim.m
字号:
function fracdim(fst,lst)
% The function
%
% fracdim(data);
%
% compute an estimation of the fractal dimension
% by the method of Grassberger and Proccacia.
% The function opens a window which allows
% to fine tune the LMS regression between
% the (log(r),log(N)) points.
% The first arg <data> contains the data distribution
% (one point or vector per row).
% Don't use the function with 2 args!
global h1;
global h2;
global h3;
global h4;
global min;
global max;
global ptlist;
if nargin==1,
%initialisation
h0 = figure(...
'position',[50,50,420,430],...
'resize','off');
h1 = uicontrol(...
'style','text',...
'position',[10,10,400,30],...
'string','Please wait while computing ...');
% sauver dans un fichier temporaire
sv(fst,'temp.dat');
% ligne a modifier en fonction du chemin vers fracdim.exe
!e:\john\ucl\doc\cda\cpp\fracdim.exe temp.dat fracdim.dat
% repecher les resultats dans le fichier temporaire
ptlist = ld('fracdim.dat');
% effacer le fichier temporaire
!del temp.dat
[i,j] = size(ptlist);
min = 1;
max = i;
set(h1,'string',strcat('LMS Regression between points <',num2str(min),'> and <',num2str(max),'>.'));
h2 = uicontrol(...
'style','slider',...
'position',[10,40,400,20],...
'min',min,...
'max',max,...
'sliderstep',[1/(max-min),2/(max-min)],...
'value',min,...
'callback','global h1; global h2; global h3; set(h2,''value'',round(get(h2,''value''))); fracdim(get(h2,''value''),get(h3,''value''))');
h3 = uicontrol(...
'style','slider',...
'position',[10,60,400,20],...
'min',min,...
'max',max,...
'sliderstep',[1/(max-min),2/(max-min)],...
'value',max,...
'callback','global h1; global h2; global h3; set(h3,''value'',round(get(h3,''value''))); fracdim(get(h2,''value''),get(h3,''value''))');
h4 = axes(...
'units','pixels',...
'position',[10,90,400,300],...
'xtick',[],...
'ytick',[]);
fracdim(min,max);
elseif nargin==2,
%regression
if fst < lst, X = [ones(lst-fst+1,1),ptlist(fst:lst,1)]; y = ptlist(fst:lst,2); b = inv(X'*X)*X'*y;
mqe = norm(y-X*b)/(lst-fst+1)
mmqe = mqe/(lst-fst+1) plot(ptlist(:,1),ptlist(:,2),'r+');
hold on; plot(X(:,2),y,'+'); AX = axis; plot( [AX(1),AX(2)], [b(1)+AX(1)*b(2),b(1)+AX(2)*b(2)] ); title(strcat('Fractal Dimension: ',num2str(b(2)))); axis(AX);
set(gca,'xtick',[],'ytick',[]); hold off;
set(h1,'string',strcat('LMS Regression between points <',num2str(fst),'> and <',num2str(lst),'>.')); else set(h1,'string','First point must precede last point.'); endend;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -