While Loop with two conditions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
While Loop with two conditions
Hi All,
I am trying to use a While Loop with two conditions, something like below:
while (x > 10) ^ (y < 100)
...
but Mathcad 15 only goes through the loop once and does not execute the iterations. If I use only one condition check, it works fine. Could someone let me know if it is correct to do what I show above?
Thank you.
Solved! Go to Solution.
- Labels:
-
Mathcad Usage
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Thanks Werner_E, for your quick response. One of the two conditions is a loop counter. I inadventantly initialized it outside the solve block. After I moved this initialzation into the solve block, it works now. I do not know why that would make a difference. Thanks again,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Obviously one of your two conditions linked with logical 'and' is not fulfilled after the first loop pass, so that no further passes are made.
To get a qualified answer to your question, you would have to specify in more detail what exactly you are doing and, of course, attach your worksheet here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Thanks Werner_E, for your quick response. One of the two conditions is a loop counter. I inadventantly initialized it outside the solve block. After I moved this initialzation into the solve block, it works now. I do not know why that would make a difference. Thanks again,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
@LC_12355277 wrote:
Thanks Werner_E, for your quick response. One of the two conditions is a loop counter. I inadventantly initialized it outside the solve block. After I moved this initialzation into the solve block, it works now. I do not know why that would make a difference. Thanks again,
Frankly, I can't make much sense of your description of the situation and I don't know how your question about a while loop suddenly has anything to do with solve block.
Therefore, I can't say anything about why the assignment to a worksheet variable changes the behavior of your program.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
The while loop is used to iteratively solve an equation. When I said a solve block, I meant inside the while loop.
