Skip to main content
13-Aquamarine
December 19, 2024
Question

Mathcad Programming

  • December 19, 2024
  • 1 reply
  • 988 views

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

23-Emerald IV
December 19, 2024

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

13-Aquamarine
December 20, 2024

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.

23-Emerald IV
December 20, 2024

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