Not enough input arguments
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Joaquin Saldain
am 24 Feb. 2018
Kommentiert: Walter Roberson
am 26 Feb. 2018
I am minimizing a function that I created. Getting "Not enough input arguments".
This is the main code:
y=data;
y0=0;
global y y0;
theta0=[0.5, 0.5];
[x,fval,exitflag,output,grad,hessian] = fminunc(condlike,theta0)
This is the function file:
function [ f ] = condlike(x )
Conditional likelihood evaluation for AR(1)
global y y0
[m,n]=size(y);
g = normpdf(y(1,1),x(1)*y0,x(2));
for i=1:n-1
g=g+log(normpdf(y(1,i+1),x(1)*y(1,i),x(2)));
end
f=-g;
end
0 Kommentare
Akzeptierte Antwort
Rik
am 24 Feb. 2018
You forgot to make the first input a function handle, using an @ character. The code below ran without errors for me.
data=rand(10,1);
global y y0;
y=data;
y0=0;
theta0=[0.5, 0.5];
[x,fval,exitflag,output,grad,hessian] = fminunc(@condlike,theta0);
function [ f ] = condlike(x )
%Conditional likelihood evaluation for AR(1)
global y y0
[~,n]=size(y);
g = normpdf(y(1,1),x(1)*y0,x(2));
for i=1:n-1
g=g+log(normpdf(y(1,i+1),x(1)*y(1,i),x(2)));
end
f=-g;
end
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Matched Filter and Ambiguity Function finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!