What is wrong with the code?
Mostrar comentarios más antiguos
I have this small code:
function test
L = 10;
t = existing_chk('L',uigetdir)
function x = existing_chk(name_x,a)
chk = exist(name_x,'var')
if chk == 0;
x = a;
else
x = eval(name_x);
end
end
end
The problem is that uigetdir is executed even though 'L' exists. I cannot figure out the problem
Respuesta aceptada
Más respuestas (1)
Daniel Shub
el 4 de Mayo de 2011
0 votos
MATLAB evaluates uigetdir before existing_chk, so that it can pass whatever uigetdir returns to existing_chk. Either turn the second argument into a function handle @()uigetdir and call a() or turn it into a string 'uigetdir' and call eval(a).
Categorías
Más información sobre Entering Commands en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!