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

Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! 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

 

4 REPLIES 4
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

NM_10165576
13-Aquamarine
(To:LucMeekes)

Hello LucMeekes
thank you for the reply.
but this is not the result i am looking for.
I just want to know, why these options are repeating.

NM_10165576_0-1734676712285.png

Is there a step i can change so that it iterates through the length of ds and give me output, without repeating the options.

LucMeekes
23-Emerald III
(To:NM_10165576)

I think I have answered your question as to why the values are repeating. To answer your new question, it is necessary to understand what you are trying to achieve with the program. That is fully unclear to me.

The info I provided about what can be omitted should at least provide you with insight about where things don't work as you may have intended. 

 

Success!

Luc

StuartBruff
23-Emerald III
(To:NM_10165576)

It may help to see what is going on if you look at the results for each value of j and both the unsorted and Upsorted Res1.  I've modified Bop to include j in the attached worksheet.  By returning more values in L1R, you should be able to see that -57.873 and -65.983 are also repeated.

 

2024 12 20 A.png

 

Stuart

Announcements

Top Tags