k=inf;
for i=1:row
if (length(find(s_path==i))==0)&(k>distance(i))
k=distance(i);
temp_2=i;
end
end
s_path=[s_path,temp_2];
temp=temp_2;
end
%output the result
path(1)=endpoint;
i=1;
while path(i)~=start
path(i+1)=flag(path(i));
i=i+1;
end
path(i)=start;
path=path(end:-1:1);
short_distance=distance(endpoint);
三 绘制差分方程的映射分叉图
function fork1(a);
% 绘制 x_(n+1)=1-a*x^2_n 映射的分叉图
% Example:
% fork1([0,2]);
N=300; % 取样点数
A=linspace(a(1),a(2),N);
starx=0.9;
Z=[];
h=waitbar(0,'please wait');m=1;
for ap=A;
x=starx;
for k=1:50;
x=1-ap*x^2;
end
for k=1:201;
x=1-ap*x^2;
Z=[Z,ap-x*i];
end
waitbar(m/N,h,['completed ',num2str(round(100*m/N)),'%'],h);
m=m+1;