資源簡介
牛頓迭代算法有一定的缺陷,這個是實現同倫算法優化初值的例子。平臺是matlab,可以參考。
代碼片段和文件信息
clear?all;?close?all;?clc;
x0?=?5;
s?=?0:0.1:1;
x_star?=zeros(length(s)1);
neginf?=?-20;?posinf?=20;?step?=?0.05;
X_Plot?=?neginf:step:posinf;
EnPlot?=?1;
if?EnPlot
???figure;plot(X_Plothxs(X_Plots(1)x0)‘r‘);
???xlabel(‘x‘);ylabel(‘H(xsx_0)‘);title(‘同倫函數曲線‘);
???grid?on;?hold?on;pause;
end
x_star(1)?=?x0;
for?i?=?2:1:11
????x_star(i)?=?NewtonIterHomo(x_star(i-1)@hxs?@gx?s(i)?1e-31);
????if?EnPlot
???????plot(X_Plot?hxs(X_Plots(i)x_star(i))‘b‘);
???????hold?on;pause;
????end
end
if?EnPlot
????hold?off;
end
figure;plot(sx_star‘.-‘‘MarkerEdgeColor‘‘r‘‘MarkerSize‘20);grid;
xlabel(‘s‘)
- 上一篇:奇異值差分譜
- 下一篇:肺實質分割Matlab.rar
評論
共有 條評論