资源简介
梯度下降法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程序
- 二元序列的Berlekamp-Massey算法的matlab程
- KPCA MATLAB程序,提供4种核函数,根据
- 频域特征值MATLAB程序
- 时域特征值MATLAB程序
- 卡尔曼滤波-Matlab程序
- 小波模极大值边缘检测+膨胀+边缘跟踪
- 图解法绘塔板图并求塔板数的matlab程
- OFDM中LS和DFT信道估计算法matlab程序实
- 节约法车路路径问题VRP的Matlab程序代
- 增广拉格朗日方法MATLAB程序
- 水果识别matlab程序,有界面
- 最优化-牛顿法求最优解matlab程序
- 梯度下降法的matlab代码,包括最小二
- 已知函数及区间,求区间内极值 mat
- 二进制引力搜索算法BGSAmatlab程序
- 万有引力算法GSA-matlab程序
- lasso回归MATLAB程序
- 面阵中二维角度估计 Unitary -ESPRIT算法
- 自适应遗传算法matlab程序
- 简支梁内力计算matlab程序
- 配电网故障定位matlab程序
- PRI变换的matlab程序
- 位势函数 matlab程序
- 三次样条插值matlab程序 含多种边界条
- SDIF算法Matlab程序
- 三维B样条曲线拟合Matlab程序
- 支持向量机 MATLAB程序
- OFDM峰平比及matlab程序仿真
- 四元数与姿态角转换matlab程序
评论
共有 条评论