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