Construct Timer using evalin

조회 수: 1 (최근 30일)
Milad Javan
Milad Javan 2011년 7월 21일
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.

채택된 답변

Daniel Shub
Daniel Shub 2011년 7월 21일
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
Milad Javan
Milad Javan 2011년 7월 21일
Finally I use timerfindall function. It's better than my method. Thanks alot.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Chirag Gupta
Chirag Gupta 2011년 7월 21일
evalin('base','Timer.Name = ''test123''');
You need to escape '
  댓글 수: 2
Milad Javan
Milad Javan 2011년 7월 21일
Thank for your answer it works.
Walter Roberson
Walter Roberson 2011년 7월 21일
Wouldn't assignin(base, 'Timer.Name', 'test123')
be more straight-forward ?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Software Development Tools에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by