最速下降法Matlab程序

最速下降法Matlab程序

ID:42739879

大?。?3.51 KB

頁數(shù):4頁

時(shí)間:2019-09-20

最速下降法Matlab程序_第1頁
最速下降法Matlab程序_第2頁
最速下降法Matlab程序_第3頁
最速下降法Matlab程序_第4頁
資源描述:

《最速下降法Matlab程序》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在應(yīng)用文檔-天天文庫。

1、%最速下降梯度法matlab程序%SteepestDescentMethod%ByKshitijDeshpandeclcclearallwarningoffprompt={'CoeficientsifX1=','CoefficientsofX2=','CoefficeintofX1X2=','InitialPoint='};def={'[210]','[1-10]','2','[00]'};a=inputdlg(prompt,'Data',1,def);a=char(a);[m,n]=size(a);x1=eval(a(1,1:n));x2=

2、eval(a(2,1:n));x1x2=eval(a(3,1:n));X1=eval(a(4,1:n));delf1(1)=polyval(polyder(x1),X1(1));delf1(1)=(delf1(1))+(x1x2*X1(2));delf1(2)=polyval(polyder(x2),X1(1));delf1(2)=(delf1(2))+(x1x2*X1(1));s=-delf1;%%%%%%%%%%%reportsrep(1,1:2)=s;%%%%%%%%%%x1new(1)=s(1)^2;x1new(2)=2*X1(1)*s(1);x1new(3)=X1(1

3、)^2;x1new=x1new*x1(1);x1new_(2)=x1(2)*s(1);x1new_(3)=x1(2)*X1(1);x1new=x1new+x1new_;x2new(1)=s(2)^2;x2new(2)=2*X1(2)*s(2);x2new(3)=X1(2)^2;x2new=x2new*x2(1);x2new_(2)=x2(2)*s(2);x2new_(3)=x2(2)*X1(2);x2new=x2new+x2new_;x1x2new(1)=s(1)*s(2);x1x2new(2)=X1(1)*s(2)+X1(2)*s(1);x1x2new(3)=X1(1)*X1

4、(2);x1x2new=x1x2*x1x2new;df=polyder(x1new+x2new+x1x2new);lambda(1)=roots(df);X1=X1+lambda(1)*s;Xrep(1,1:2)=X1;delf1(1)=polyval(polyder(x1),X1(1));delf1(1)=(delf1(1))+(x1x2*X1(2));delf1(2)=polyval(polyder(x2),X1(2));delf1(2)=(delf1(2))+(x1x2*X1(1));ifall(X1)==0fprintf('%d%distheoptimumpoint

5、',X1(1),X1(2));enditrep(1)=1;it=2;whileall(delf1)==1s=-delf1;x1new(1)=s(1)^2;x1new(2)=2*X1(1)*s(1);x1new(3)=X1(1)^2;x1new=x1new*x1(1);x1new_(2)=x1(2)*s(1);x1new_(3)=x1(2)*X1(1);x1new=x1new+x1new_;x2new(1)=s(2)^2;x2new(2)=2*X1(2)*s(2);x2new(3)=X1(2)^2;x2new=x2new*x2(1);x2new_(2)=x2(2)*s(2);x2

6、new_(3)=x2(2)*X1(2);x2new=x2new+x2new_;x1x2new(1)=s(1)*s(2);x1x2new(2)=X1(1)*s(2)+X1(2)*s(1);x1x2new(3)=X1(1)*X1(2);x1x2new=x1x2*x1x2new;df=polyder(x1new+x2new+x1x2new);lambda(it)=roots(df);X1=X1+lambda(it)*s;delf1(1)=polyval(polyder(x1),X1(1));delf1(1)=(delf1(1))+(x1x2*X1(2));delf1(2)=polyv

7、al(polyder(x2),X1(2));delf1(2)=(delf1(2))+(x1x2*X1(1));itrep(it)=it;srep(it,1:2)=s;Xrep(it,1:2)=X1;it=it+1;end[m,n]=size(itrep);matrix=[itrep'srep(1:n,1)srep(1:n,2)Xrep(1:n,1)Xrep(1:n,2)];answer=char(num2str(X1));answer=['Theoptimalpointis['answ

當(dāng)前文檔最多預(yù)覽五頁,下載文檔查看全文

此文檔下載收益歸作者所有

當(dāng)前文檔最多預(yù)覽五頁,下載文檔查看全文
溫馨提示:
1. 部分包含數(shù)學(xué)公式或PPT動(dòng)畫的文件,查看預(yù)覽時(shí)可能會(huì)顯示錯(cuò)亂或異常,文件下載后無此問題,請放心下載。
2. 本文檔由用戶上傳,版權(quán)歸屬用戶,天天文庫負(fù)責(zé)整理代發(fā)布。如果您對本文檔版權(quán)有爭議請及時(shí)聯(lián)系客服。
3. 下載前請仔細(xì)閱讀文檔內(nèi)容,確認(rèn)文檔內(nèi)容符合您的需求后進(jìn)行下載,若出現(xiàn)內(nèi)容與標(biāo)題不符可向本站投訴處理。
4. 下載文檔時(shí)可能由于網(wǎng)絡(luò)波動(dòng)等原因無法下載或下載錯(cuò)誤,付費(fèi)完成后未能成功下載的用戶請聯(lián)系客服處理。