资源简介
梯度下降法matlab程序,需要手动输入参数梯度下降法matlab程序,需要手动输入参数

代码片段和文件信息
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Developed by Bapi Chatterjee IIT Delhi India %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% The script steepest.m optimizes a multivariable function using steepest
% descent method.
% Input:
% 1)Dimensionality of the multivariable function.
% 2)Function in the proper format.
% Note: Kindly ensure that the function is entered in the proper
% format readable by MATLAB. This is the only point where the
% maximum possibility of error is there.
% 3)Initial approximation vector.
% Note: Kindly ensure that the dimensionalty matches with the
% dimension of initial approximation vector.
% 4)Error tolerance.
%
% For the theory of steepest decent method see “Practical methods of
% optimization- R. Fletcher Second edition 2003 John Wiley & Sons“ or
% any other good book on unconstrained optimization methods.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
disp(‘Would you like to clear your workspace memory and command screen?‘);
z=input(‘To do so enter 1 any other number to continue:‘);
if z==1
clc;clear
end
choice=input(‘To do a maximization enter 1 for minimization enter 2:‘);a=2;
while a==2
if choice~=1&&choice~=2
disp(‘Wrong input!‘);a=2;
choice=input(‘To do a maximization enter 1 for minimization enter 2:‘);
else
a=1;
end
end
a=2;
mark=0;
flag=0;
count=0;
syms b;
u=[];
warning off all
try
while a==2
n=floor(input(‘Enter the dimension of function:‘));
if n<1
disp(‘Kindly enter a positive integer‘);a=2;
else
a=1;
end
end
catch
disp(‘Kindly enter a positive integer‘);
end
a=2;
for i=1:n
syms ([‘x‘ num2str(i)]);
end
while a==2
try
f=input(‘Enter the function in terms of variables x_i(i.e. x1x2etc.):‘);a=1;
catch
disp(‘Kindly recheck the index of variables and format of expression!‘);a=2;
end
end
if choice==1
f=-f;
end
x0=input(‘Enter the initial approximation row vector of variables:‘);a=2;
while a==2
if length(x0)~=n
disp(‘The dimension of initial approximation is incorrect!‘);a=2;
x0=input(‘Enter the initial approximation as row vector of variables:‘);
else
a=1;
end
end
try
eps=abs(input(‘Enter the error tolerance:‘));
catch
disp(‘Kindly enter a real number!‘);
end
g=f;
try
for i=1:n
h(i)=diff(g[‘x‘ num2str(i)]);
for j=1:n
k(ij)=diff(h(i)[‘x‘ num2str(j)]);
end
end
catch
disp(‘Your optimization problem can not be solved‘);
return
end
disp(‘Hessian matrix of the function=‘)
if choice==1
disp(-k)
elseif choice==2
disp(k)
end
for i=1:n
for j=1:n
if i==j
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 8987 2019-06-04 10:45 steep.m
I..D... 0 2019-06-04 10:50 亲测可用
----------- --------- ---------- ----- ----
8987 2
相关资源
- 组合导航matlab程序
- 替代数据法的matlab程序
- 神经网络分类matlab程序
- matlab程序用Hopfield网络解决TSP
- 多用户检测MATLAB程序
- 实现2ask.4ask.2fsk.4fsk.qam16.qam8调制的m
- matlab 手动画图 描点画图
- 曲线旋转得到曲面的MATLAB程序
- 主动轮廓模型算法matlab程序
- Lozi混沌系统相关分析的MATLAB程序
- 用蚁群算法求解TSP问题的matlab程序
- 分数阶chen混沌matlab程序
- 基于粒子群算法的非合作博弈的matl
- KF+EKF matlab程序实现
- 圆拟合matlab程序,以及圆心 半径的确
- stlwritematlab程序
- 层次分析法的matlab程序
- 泊松过程的模拟及检验 matlab程序
- 世上最牛的23个图像跟踪算法MATLAB程序
- 散点拟合平面的MATLAB程序
- 信号检测与估计-理论与应用答案及
- ROC曲线MATLAB程序
- dijkstra算法改进的matlab程序能求出两点
- EEMD的MATLAB程序
- 基于遗传算法的机器人路径规划matl
- 基于自适应压扩法降低OFDM系统的峰均
- 求露点温度matlab程序
- 计算图像Spatial Frequence的Matlab程序SF
- 德州扑克获胜概率计算的MATLAB程序
- 数模美赛常用模型算法matlab程序包+数
评论
共有 条评论