필터 지우기
필터 지우기

Global Flag

조회 수: 3 (최근 30일)
Bestun
Bestun 2012년 4월 17일
Dear All
I am using flag in my code and when I run the code with these set of parameters
HenXoma(1, 9.81, 0.017, 1, 8.8, 15.2, 1, 1, 0, 0, 2, 4, 0, 36.9, 15.2)
I got a solution of 30.2 (this number is just for explaining)
Then When I am changing the fourth input parameter which is =(1) to (0)(lets call this parameter Yw), I got the same solution (30.2). It should be different solution.
After debugging I found that Matlab took the previous value of Yw as (1) not the new value (0). Also I made clear in the command window to ensure that the work space is cleared.but I got the same answer I appreciate any useful suggestion and thanks for your help.

채택된 답변

Image Analyst
Image Analyst 2012년 4월 17일
I'd say that Yw is not used, or has no effect, in the internal code of HenXoma (which we can't see because you didn't post it.) Why don't you post it.
If Yw is a global variable (I assume that's what "Glabal" means to you), you don't need to pass it via the argument list, you just declare it global inside the function.
  댓글 수: 3
Walter Roberson
Walter Roberson 2012년 4월 18일
Yw has no effect on your code if the global variable "flag" is 2. At present we have no way of knowing what its value is.
Bestun
Bestun 2012년 4월 18일
Dear Walter
I am taking flag = 1 , so there is effect of Yw on the dlor function . Yes if flag = 2 , the code is running a test of the equations which are not depending on Yw value.
However, changing Yw from 0 to 1 does not change the solution (in my equations Yw is dependent variable) at all and it must be change
Regards

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by