Unrecognized function or variable 'X', where is the error ? I have tired all the things and solution but the problem wont fix , please help its urgent Thank you

12 ビュー (過去 30 日間)

回答 (1 件)

Geoff Hayes
Geoff Hayes 2020 年 4 月 1 日
harshit - you are calling your function, from the command line as
>> computeCost(X, y, theta)
which is fine as it does match the signature of this function in so much as it requires three input parameters/variables. But have you defined these variables prior to trying to use them? The error message is telling you that you haven't (i.e. you are trying to use a variable that does not exist). You would need to define this as
>> X = 1:1:10;
>> y = sin(X);
>> theta = 42;
>> computeCost(X, y, theta)
Note that the above values I've assigned to these three variables are for example purposes only. I don't know what the correct values should be...

Community Treasure Hunt

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

Start Hunting!

Translated by