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

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

Mathcad programming

NM_10165576
13-Aquamarine

Mathcad programming

Hello everyone,
In the attached file i have two programs r and q.
program 'r' arranges the bars in one layer of beam cross section and 'q' is for the second layer.
Here the number of layers are decided based on 'gqo' values.
If they are positive, one layer of the bars are sufficient, i have to repeate the proceedure until it is positive (which means i have to arrange the bars in several layers).

How can i automate y1....yn, d1....dn, n1.....nn, so that one program is sufficient to give the results for the bars in several layers. (y1,y2), (d1,d2), (n1,n2) belongs to first layer, (y3,y4).... for second layer, (y5,y6) for third layer and soo on.
Attached mathcad 10 file.

ACCEPTED SOLUTION

Accepted Solutions
StuartBruff
23-Emerald III
(To:NM_10165576)

What is the purpose of the variable i within the r and q programs.  AFAICT, you increment i within the d1 loop in r but not in d3 in q (i remains at 0 throughout).  Putting i into the d3 loop raises an indexing error (the indexed value of ds doesn't exist)

 

Also, why do you return six rows for r and q? Is it for debugging purposes, and would you expect to just return the top Res row in the fully developed worksheet?

 

Considering the previous paragraph, in q, you pick n1, d1, n2, and d2 with i set to 0, which selects the values from the 1st row of r.  Did you intend to pick the values from different rows of q for subsequent layers?  It makes more sense to me if you only want to return one Res row from each layer and then index into that for subsequent layers.

 

Finally, for now, the obvious thing to do is generalize q.  This leaves the problem of dealing with r.  If you use q's program to calculate r, are there "initial" values that could be used for n1, d1, n2 & d2?  I had thought 0, as this would seem to leave the calculated values alone ... except for that 9th and 4th power roots.  Do powers of the roots change with each layer, or is the 1st layer a special case?

 

Stuart

View solution in original post

8 REPLIES 8

Hi @NM_10165576,

Thank you for your question!

Your post appears well documented but has not yet received any response. I am replying to raise awareness. Hopefully, another community member will be able to help.

Also, feel free to add any additional information you think might be relevant.

 

Best regards,

Catalina
PTC Community Moderator

 Good morning NM_10165576 , What is your objective here?    It kind of sounds like you are trying to calculate cross sectional properties.  Would you be able to supplement your Mathcad sheet with a detailed sketch of the physical problem with detailed dimensions and variable/parameter labeling?   Please add additional details so we can try to help!

Hello @Structures_401 
i have attached a picture here.
as shown in the picture i have to take output from program 'r' and then run program 'q'.
How can i combine both the programs. It should also work for multiple layers.

NM_10165576_0-1727756600967.png

 

StuartBruff
23-Emerald III
(To:NM_10165576)

What is the purpose of the variable i within the r and q programs.  AFAICT, you increment i within the d1 loop in r but not in d3 in q (i remains at 0 throughout).  Putting i into the d3 loop raises an indexing error (the indexed value of ds doesn't exist)

 

Also, why do you return six rows for r and q? Is it for debugging purposes, and would you expect to just return the top Res row in the fully developed worksheet?

 

Considering the previous paragraph, in q, you pick n1, d1, n2, and d2 with i set to 0, which selects the values from the 1st row of r.  Did you intend to pick the values from different rows of q for subsequent layers?  It makes more sense to me if you only want to return one Res row from each layer and then index into that for subsequent layers.

 

Finally, for now, the obvious thing to do is generalize q.  This leaves the problem of dealing with r.  If you use q's program to calculate r, are there "initial" values that could be used for n1, d1, n2 & d2?  I had thought 0, as this would seem to leave the calculated values alone ... except for that 9th and 4th power roots.  Do powers of the roots change with each layer, or is the 1st layer a special case?

 

Stuart

The purpose of i in both r and q is to iterate through the length of ds. that means the first value of d1 or d3 should be 28mm and for d2 or d4 it should be 25mm. 

i just need top six rows from iteration, so i am returning top six based on lesser gqo value.

i can take 4th power common for all the layers. 

StuartBruff
23-Emerald III
(To:NM_10165576)


@NM_10165576 wrote:

The purpose of i in both r and q is to iterate through the length of ds. that means the first value of d1 or d3 should be 28mm and for d2 or d4 it should be 25mm. 

i just need top six rows from iteration, so i am returning top six based on lesser gqo value.

i can take 4th power common for all the layers. 


OK.

 

I was looking for areas of commonality to try and make a consistent loop for all layers, including the first one.  So I copied q and added do-nothing rows r to align it as closely as I could with q.

 

If I understand you correctly, you keep 6 rows of data for each layer.

 

In r you increment i within the d1 loop but you increment it outside of the d3 loop in q.

 

Does q give the correct results if i doesn't increment within the d3 loop?

 

StuartBruff_2-1727786567330.png

 

In q, you set i to zero before the d3 loop, as per r, and then assign the variables n1, d1, n2, & d2 indexing into r.  

 

StuartBruff_1-1727786206395.png

 

This raises an error if you increment i within the d3 loop, as i becomes greater than the allowed row index for r.

 

Do you intend to keep each layer's results in a separate matrix or will you stack them (if so, will i need to change with each layer calculation?)?

 

You don't have any equivalents of n1, etc in r, and your equations reflect this, so there is no problem with indexing any notional previous result. 

 

You handle i being greater than the allowed index for ds by an if statement, so i being too large doesn't raise an error..

 

StuartBruff_3-1727786939732.png

 

How does the 9th root figure into the calculation of gqo?  Is that a typo (should be 4 not 9)? If not, do the powers vary with subsequent layers?

 

StuartBruff_0-1727785935241.png

 

Stuart

Hi
forget about program q. I just want to know, is there is any way i can replace d1 with d3, n1 with n3,d2 with d4, n2 with n4 and redo the calculations till step n2 to loop, using d3,d4,n3,n4 in place of d1,d2,n1,n2. And finally combining the results of both d1,d2,d3,d4,n1,n2,n3,n4 to calculate Sp ans A.
And there is a condition, i have to replace d1,d2,n1,n2 with d3,d4,n3,n4 only if gqo is less than 0. Otherwise Sp, A will be calculated only with d1,d2,n1,n2.

Here i am explaing only about program r.

Announcements

Top Tags