Why do I get "Undefined function or variable 'var'."
Información
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
Mostrar comentarios más antiguos
Hi, My code is a for loop which runs a function tsp_ga.m n times. this function (tsp_ga) gives a result "minDist". So my objective is to store the n obtained results in a vector. And to do it I Wrote the following code:
for kk=1:5
k
tsp_ga
ss(kk)=minDist
end
But it gave the following error: " Undefined function or variable 'minDist'.
Error in (line 4) ss(kk)=minDist_ ".
PS.: you will find attached the function tsp_ga.
Thank you in advance.
3 comentarios
The line shown in the error message does not exist in the function tsp_ga. Therefore the error occurs somewhere else. Presumably wherever that line is minDist is not defined. So far you have not shown anything that would explain minDist being defined in whatever workspace that that line of code runs in.
I guess you magically expect minDist to jump out of the function workspace into the base/some other workspace. This does not occur: you will need to pass all the required variables as input/output arguments.
You also seem to be ignoring the plentiful examples that Joseph Kirk wrote in the help of that function. The help refers to minDist as a field of the output structure.
Nour BS
el 14 de Nov. de 2017
Stephen23
el 15 de Nov. de 2017
See this answer to your later identical question:
Respuestas (0)
La pregunta está cerrada.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!