필터 지우기
필터 지우기

Quasi newton method for optimization

조회 수: 85 (최근 30일)
christina
christina 2018년 6월 22일
댓글: HN 2020년 10월 15일
I am trying to solve the above objective function for theta using quasi newton method. But I am getting the following error. Can somebody please help me fix this error?
Following is my matlab code:
Code for defining objective function:
function f = objfun(x_t,c_n,theta)
t=0:length(x_t)-1;
L=length(t);
n=0:length(c_n)-1;
N=length(n);
for i=1:L
for j=1:N
f=@(theta) sum((x_t(i)-sum(c_n(j).*exp(-((t(i)-n(j)*a)^2/theta^2))))^2)
end
end
end
Code for calling objective function:
a = 1;
x_t=rand(32,1);
c_n=rand(32,1);
f = @(theta) objfun(x_t,c_n,theta)
theta0 = 20;
options = optimoptions('fminunc','Algorithm','quasi-newton');
[theta, thetaval] = fminunc(f,theta0,options)
%

채택된 답변

Alan Weiss
Alan Weiss 2018년 6월 22일
Try this for your function:
function f = objfuntc(x_t,c_n,theta)
L = length(x_t);
N = length(c_n);
f = 0;
for t = 1:L
xs = 0;
for n = 1:N
xs = xs + c_n(n)*exp(-(((t-n)/theta)^2));
end
f = f + (x_t(t) - xs)^2;
end
Call it like this:
a = 1;
x_t = rand(32,1);
c_n = rand(32,1);
f = @(theta) objfuntc(x_t,c_n,theta)
theta0 = 20;
options = optimoptions('fminunc','Algorithm','quasi-newton');
[theta, thetaval] = fminunc(f,theta0,options)
Alan Weiss
MATLAB mathematical toolbox documentation
  댓글 수: 5
Alan Weiss
Alan Weiss 2020년 10월 14일
Sorry, I don't know what you are asking. Please start a new question with a clear problem statement.
Alan Weiss
MATLAB mathematical toolbox documentation
HN
HN 2020년 10월 15일
Ok, thank you.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

victor d
victor d 2019년 2월 12일
In my Research (data in Excel format )
5 independent variables
1 dependent variables.
So i need to do the following neural Network algorithms.
1.Backpropagation algorithms
2.conjugate gradient method
3.Quasi-Newton method

카테고리

Help CenterFile Exchange에서 Nonlinear Optimization에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by