I have error "Unrecognized function or variable 'X'" when calling computeCost(X, y, theta)
Ältere Kommentare anzeigen
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
Antworten (2)
KSSV
am 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 Kommentar
Younes IDRISSI
am 10 Feb. 2021
Younes IDRISSI
am 10 Feb. 2021
0 Stimmen
Kategorien
Mehr zu Data Type Conversion finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!