I have error "Unrecognized function or variable 'X'" when calling computeCost(X, y, theta)
Mostrar comentarios más antiguos
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
Respuestas (2)
KSSV
el 10 de Feb. de 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 comentario
Younes IDRISSI
el 10 de Feb. de 2021
Younes IDRISSI
el 10 de Feb. de 2021
0 votos
Categorías
Más información sobre Sparse Matrices en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!