"Error not enough input arguments "
1 view (last 30 days)
This is my code and I am getting error" not enough input parameters" in line 4 .Can anyone please rectify the problem ?
function[jval, gradient]= costfuntion(theta)
jval= (theta(1)-5)^2 + ...
options = optimset('GradObj','on', 'MaxIte', 100);
[optTheta,funcval, exitFlag]= fminunc(@costfunction, initialTheta, options);
KSSV on 13 Jun 2020
I think you are running your code by using either run button or F5 button. This is a function, you cannot run like that. You need to save it in a directory on the name costfunction.m. And call it in command window.
theta = rand(1,2) ; % some random values for demo
[jval, gradient]= costfunction(theta) ;
I have checked the code, it is running fine.