加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

[转载]matlab  计算hessian矩阵

(2012-12-04 11:04:54)
标签:

转载

原文地址:matlab  计算hessian矩阵作者:abcuy

function H=hessian(f,x,x0)

% H=hessian(f,x) 计算表达式
% H=hessian(f,x,x0) 计算hessian矩阵的值 x0为x的初值

%$copyright by$ LUO sir

switch  nargin
    case 1
    error('please input variables in f(x)')

    case 2
        H=subhessian(f,x);
 
    case 3
        H=subhessian(f,x,x0);
        x=x0;
        H=subs(H);
    otherwise
       
         error('too many arguments or nothing')         
end

function HH=subhessian(f,x,x0)
 
n=length(x);

J=jacobian(f,x);
HH=[];
HH=sym(HH);
for i=1:n
HH(i,:)=jacobian(J(1,i),x);
end

0

  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有