cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

Mathcad Programming

NM_10165576
13-Aquamarine

Mathcad Programming

Hello everyone,
in the attached file, i am not understanding how the program r2 iterates.
Could someone please explain why I am receiving the same options multiple times in the output.
Attached Mathcad 10 sheet.

NM_10165576_0-1734581432499.png

 

1 REPLY 1
LucMeekes
23-Emerald III
(To:NM_10165576)

Simple.

Your r2 program contains 2 nested loops, the first over Layer (0,2..3).

The internals of that loop only do something is when Layer=2 (So the for loop is useless).

Another part of the internals is the second for loop over j (0..rows(ds)-2).

The internals of this loop result in values for d1, d2 and sub1, which may be different for each value of j, but what counts is when the loop is done: You have the values for d1 d2 and sub1 only for j=rows(ds)-2.

Then you take a submatrix of that res1 into Res1 and finally a submatrix of Res1 into L1R which is the reult of your r1 program.

You can simplify the program by:

- omitting the definition of sub (because it is not used)

- replacing the "for Layer ... if Layer=2" with "Layer <- 2"

- replacing "for j...2" with "j <- rows(ds)-2"

This should result in the same matrix output, but I guess that's not what you are after.

 

Success!
Luc

Announcements

Top Tags