How to use who within eval
Mostrar comentarios más antiguos
Here is the code:
file_name = 'test';
eval(['file_length = length(who(''-file'',' file_name '));']);
But this doesn't work, because who requires a quoted string as a variable. Then I tried this,
eval(['file_length = length(who(''-file'', ''file_name'' ));']);
It didn't work, apparently. Now file_name showed up instead of the value I put in it. This sounds a very simple question, but I just don't know what to do. Help!
Respuesta aceptada
Más respuestas (2)
Sean de Wolski
el 9 de En. de 2012
2 votos
Why use eval? Nothing in that statement looks like it couldn't be done without it.
the cyclist
el 9 de En. de 2012
Agree with Sean that you do not need eval() here. Try this:
file_name = 'test';
file_length = length(who('-file',file_name));
Categorías
Más información sobre Whos 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!