• / 4
  • 下载费用:10 金币  

最速下降法Matlab程序.doc

关 键 词:
最速下降法Matlab程序.doc
资源描述:
%最速下降梯度法 matlab 程序% Steepest Descent Method% By Kshitij Deshpandeclcclear allwarning offprompt = {\'Coeficients if X1=\',\'Coefficients of X2=\',\'Coefficeint of X1X2=\',\'Initial Point=\'};def = {\'[2 1 0]\',\'[1 -1 0]\',\'2\',\'[0 0]\'};a=inputdlg(prompt,\'Data\',1,def);a=char(a);[m,n]=size(a);x1 = eval(a(1,1:n));x2=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)^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(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));if all(X1)== 0fprintf(\'%d %d is the optimum point\',X1(1),X1(2));enditrep(1)=1;it=2;while all(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);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(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) = polyval(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:
展开阅读全文
  微传网所有资源均是用户自行上传分享,仅供网友学习交流,未经上传用户书面授权,请勿作他用。
0条评论

还可以输入200字符

暂无评论,赶快抢占沙发吧。

关于本文
本文标题:最速下降法Matlab程序.doc
链接地址:https://www.weizhuannet.com/p-9785455.html
微传网是一个办公文档、学习资料下载的在线文档分享平台!

微传网博客

网站资源均来自网络,如有侵权,请联系客服删除!

 网站客服QQ:80879498  会员QQ群:727456886

copyright@ 2018-2028 微传网络工作室版权所有

     经营许可证编号:冀ICP备18006529号-1 ,公安局备案号:13028102000124

收起
展开