MathCAD unexpectedly Exiting Nested For Loop
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
MathCAD unexpectedly Exiting Nested For Loop
I have a Prime 7.0 worksheet with two matrices (of immediate interest). They are w [1x3] and P [3x2].
I am trying to manipulate and ensure that they have the same number of rows. And trying to do it with a nested loop.
BUT the inner loop seems to work once and then returns the matrix. The outer loop never increments to the next step.
I'm obviously doing something wrong, but can't see it.
If anyone could point me in the right direction, that would be great. Thanks!
FOR i: 1 TO rows(P)
---> FOR j: 1 TO rows(w)
---> ---> IF (criteria)
---> ---> ---> STACK (new row to w)
---> ---> ---> GOTO / SKIPTO next i
Solved! Go to Solution.
- Labels:
-
Mathcad Usage
-
Programming
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
In your outermost for loop, the second assignment:
changes P from a 3x2 matrix into a scalar.
That should lead to an error for the preceding assignment:
when i is the next value (2) . For some reason it doesn't get there.
Ah, I see; the outer loop is only run for i=1 because your:
is part of the outer For loop. Note that a return statement ends the program. You exit the program before you reach the end of the outer For loop.
Success!
Luc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
In your outermost for loop, the second assignment:
changes P from a 3x2 matrix into a scalar.
That should lead to an error for the preceding assignment:
when i is the next value (2) . For some reason it doesn't get there.
Ah, I see; the outer loop is only run for i=1 because your:
is part of the outer For loop. Note that a return statement ends the program. You exit the program before you reach the end of the outer For loop.
Success!
Luc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
The worksheet is still just a work in progress, but that solved that issue! 👍
