Borrar filtros
Borrar filtros

Construct Timer using evalin

2 visualizaciones (últimos 30 días)
Milad Javan
Milad Javan el 21 de Jul. de 2011
I am working on a gui and I want to make a timer in workspace. I use this command but it occured error:
evalin('base','Timer=timer');
evalin('base',['Timer.Name=' 'Timer01']); It cannot change timer name. Please help me.

Respuesta aceptada

Daniel Shub
Daniel Shub el 21 de Jul. de 2011
Creating the timer in the base workspace may make sense, if you really want the variable Timer to be there, but it is not likely what you want to do. Timer objects are handle objects and you can create the object in one workspace and then get the object with timerfindall from any workspace.
There is no reason that you need to rename the timer object in the base workspace. You can find the object in your current workspace and rename it there.
Even better would be to rename the timer when you create it
evalin('base','Timer=timer(''Name'', ''Timer01'')');
  1 comentario
Milad Javan
Milad Javan el 21 de Jul. de 2011
Finally I use timerfindall function. It's better than my method. Thanks alot.

Iniciar sesión para comentar.

Más respuestas (1)

Chirag Gupta
Chirag Gupta el 21 de Jul. de 2011
evalin('base','Timer.Name = ''test123''');
You need to escape '
  2 comentarios
Milad Javan
Milad Javan el 21 de Jul. de 2011
Thank for your answer it works.
Walter Roberson
Walter Roberson el 21 de Jul. de 2011
Wouldn't assignin(base, 'Timer.Name', 'test123')
be more straight-forward ?

Iniciar sesión para comentar.

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by