필터 지우기
필터 지우기

execution order

조회 수: 9 (최근 30일)
Baba
Baba 2011년 11월 17일
What is the easiest way to control execution order of your code?
i have a function that creates an array of numbers and then I have a for loop that needs to use some numbers from that array. but the for loop seesms to be executing first.
  댓글 수: 4
Walter Roberson
Walter Roberson 2011년 11월 17일
No, in such a situation, the "time" variable would get populated before the "for" loop starts.
However, please remember that "time" is the name of a MATLAB library routine, and functions cannot be named "function". When you use library routine names as variables, it is common to run in to unexpected effects.
Baba
Baba 2011년 11월 17일
thank you!

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

채택된 답변

Jan
Jan 2011년 11월 17일
Matlab executes the code line by line in serial order. Inside a line the commands are executed from left to right.
Callbacks and timer functions are processed, if the command prompt is reached, or if PAUSE or DRAWNOW trigger their execution.
I do not see any possibilities to influence the order of execution.
  댓글 수: 7
Daniel Shub
Daniel Shub 2011년 11월 17일
@Walter, understanding timers is not that easy (and I am not sure you are implying it is easy). See my new question: http://www.mathworks.com/matlabcentral/answers/21537-what-thread-do-timers-operate-in
Jan
Jan 2011년 11월 17일
@Jonathan: Exactly. Inside a line the precedence order rules, but for the same precedence the left operation is performed at first.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by