hey ,i am using this function to implement gradient descent but it returns only the theta value not the J_history value,Please help me in this situtation

2 views (last 30 days)
function [theta,J_history] = gradientDescent(X, y, theta, alpha, num_iters)
% Initialize some useful values
m = length(y); % number of training examples
J_history = zeros(num_iters, 1);
for iter = 1:num_iters
% Save the cost J in every iteration
J_history(iter) = computeCost(X, y, theta);

Answers (1)

Rohit Kulkarni
Rohit Kulkarni on 2 Jul 2022
Edited: Rohit Kulkarni on 2 Jul 2022
Hi Ashok,
Are you facing this same issue :
The answer to this may solve your problem.

Community Treasure Hunt

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

Start Hunting!

Translated by