im running below code in matlab online for my machine learning in coursera, can any one pls help for this error
function J = computeCostMulti(X, y, theta)
%COMPUTECOSTMULTI Compute cost for linear regression with multiple variables
% J = COMPUTECOSTMULTI(X, y, theta) computes the cost of using theta as the
% parameter for linear regression to fit the data points in X and y
% Initialize some useful values
m = length(y); % number of training examples
% You need to return the following variables correctly
J = 0;
% ====================== YOUR CODE HERE ======================
% Instructions: Compute the cost of a particular choice of theta
% You should set J to the cost.
J = (1/(2*m))*sum(((X*theta) - y).^2)
% =========================================================================
end
in command window the error is:
Not enough input arguments.
Error in computeCostMulti (line 7)
m = length(y); % number of training examples

回答 (1 件)

madhan ravi
madhan ravi 2020 年 7 月 14 日

1 投票

Type the below in command window:
X = 1;
y = 2;
theta = 3;
J = computeCostMulti(X, y, theta)
doc function % please read it

カテゴリ

ヘルプ センター および File ExchangeGet Started with Statistics and Machine Learning Toolbox についてさらに検索

質問済み:

2020 年 7 月 14 日

回答済み:

2020 年 7 月 14 日

Community Treasure Hunt

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

Start Hunting!

Translated by