I have error "Unrecognized function or variable 'X'" when calling computeCost(X, y, theta)
Show older comments
Hello,
I have code that funtions well when I run it with the "Run button" inside my function computeCost(X, y, theta).
Unfortunately, when I type on the commande line computeCost(X, y, theta) I get the error Unrecognized function or variable 'X'
X, y and theta are well initialized within my code.
computeCost(X, y, theta)
Unrecognized function or variable 'X'.
It is the call to the function in the prompt who raise this error. This doesn't allow me to call the function with other parameters
Can you please help?
Best Regards
Younes
Answers (2)
KSSV
on 10 Feb 2021
You are running a function, this is not the way to call a function. You need to define the variables first and then call the function.
X = yourvariale; % define your variable
x = yourvariable ; % defin your variable
theta = yourvariable ; % define your variable
computeCost(X, y, theta) ;
You need to do the above in a file/ work space where the function is present.
1 Comment
Younes IDRISSI
on 10 Feb 2021
Younes IDRISSI
on 10 Feb 2021
0 votes
Categories
Find more on Data Type Conversion in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!