MATLAB學習之函數 定義一個函數來計算代價函數。 MATLAB學習之函數 x的第一列為x0,第二列為y的值 y為y的值 MATLAB學習之函數 MATLAB學習之函數 當θ = [0 1]時剛好拟合,j = 0,而取其他時大于0,代價函數不是最小。 梯度下降公式圖: MATLAB學習之函數