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

Community Tip - Need help navigating or using the PTC Community? Contact the community team. X

Translate the entire conversation x

How to generate a table from input using programming

YA_10963798
14-Alexandrite

How to generate a table from input using programming

Hi there , 

I need to create this table using programing

YA_10963798_0-1737292938654.png

I wrote this program , but it doesn't give me the answer I want: 

YA_10963798_1-1737293000978.png

What I wrote in the program is 

if the bottom value is between z and d .....> the layer is drained and use the angle (alfa) 

if the bottom is greater than d and smaller than z ....> the layer is partially drained and use the angle (alfa)

 

otherwise write the layer is not drained 

 

I need the answer two have 3 columns

1# ( layer ( drained-partially- not drained)

2# the angle if it is  drained or partially drained .. if not drained show zero 

3# if it is possible this column as well which is the layer kind it is in the table in the sheet as input 

YA_10963798_2-1737293451952.png

Thanks 

Yusra

 

The sheet is attached prime 10

ACCEPTED SOLUTION

Accepted Solutions
Werner_E
25-Diamond I
(To:YA_10963798)

  • You overwrite "layer[i" ("drained", etc.) immediately with the angle and so you lose that information. Either use a different variable for the angle vector and augment the vectors when you return the result or create "layer" as a matrix with two columns, using a second index (O and O+1).
  • Additionally you forgot to return the vector(s) you created and so the return value of your program is just the last result of the loop.
  • When you create your input table you have to use text (strings) for "sand" and "clay", otherwise you get the error as of undefined variables. It was easier for me to define the two variables with string values but of course normally you would type the strings directly in the table.

Werner_E_0-1737300748977.png

 

This is what it would look like using a second vector for the angle and returning the augmented result

Werner_E_0-1737299601977.png

You could also do without the vector 'angle" as is it is the very same as the vector phi in your input table!

 

But it looks to me that you use a faulty logic as you never can arrive at the "not drained" branch.

You have four different branches in your program but there only are three different locations for 'bottom'!

It can be

1) larger than z (above -0.62,)

2) between d and z (between -2.4 m and -0.62 m)

or

3) lower than d (below -2,4 m).

 

I don't know which of the three sections you would call "drained", "partially drained" or "not drained".
But you sure don't need four branches in your program to distinct between the three different locations.

 

The logic in your program is that a value between d and z is called "drained" and everything else is called "partially drained".
I guess that's not as it should be,

 

Prime 10 sheet attached

View solution in original post

6 REPLIES 6
Werner_E
25-Diamond I
(To:YA_10963798)

  • You overwrite "layer[i" ("drained", etc.) immediately with the angle and so you lose that information. Either use a different variable for the angle vector and augment the vectors when you return the result or create "layer" as a matrix with two columns, using a second index (O and O+1).
  • Additionally you forgot to return the vector(s) you created and so the return value of your program is just the last result of the loop.
  • When you create your input table you have to use text (strings) for "sand" and "clay", otherwise you get the error as of undefined variables. It was easier for me to define the two variables with string values but of course normally you would type the strings directly in the table.

Werner_E_0-1737300748977.png

 

This is what it would look like using a second vector for the angle and returning the augmented result

Werner_E_0-1737299601977.png

You could also do without the vector 'angle" as is it is the very same as the vector phi in your input table!

 

But it looks to me that you use a faulty logic as you never can arrive at the "not drained" branch.

You have four different branches in your program but there only are three different locations for 'bottom'!

It can be

1) larger than z (above -0.62,)

2) between d and z (between -2.4 m and -0.62 m)

or

3) lower than d (below -2,4 m).

 

I don't know which of the three sections you would call "drained", "partially drained" or "not drained".
But you sure don't need four branches in your program to distinct between the three different locations.

 

The logic in your program is that a value between d and z is called "drained" and everything else is called "partially drained".
I guess that's not as it should be,

 

Prime 10 sheet attached

YA_10963798
14-Alexandrite
(To:Werner_E)

Hi Werner,

 

Yes I wrote the conditions wrong . They should be as you suggested. 

Thank you 

Werner_E
25-Diamond I
(To:YA_10963798)

As the angle and the type are just taken from the input table, you may also use something like this:

Werner_E_1-1737310455049.png

 

I used "lower"; "between" and "higher" because I am still unsure which depth should be named "drained", etc. 😉

 

Instead of using the if-function as shown above you could also use the programmed if-condition. It looks clearer, I think, at the cost of taking up much more vertical space. I also added a row to the input data so that  all three possible cases can be checked.

Werner_E_2-1737310838600.png

 

 

YA_10963798
14-Alexandrite
(To:Werner_E)

That's even better. Can I show the angles in degree like in the table not in radian 

Werner_E
25-Diamond I
(To:YA_10963798)


@YA_10963798 wrote:

That's even better. Can I show the angles in degree like in the table not in radian 


You can show the value in degree, but not the degree sign °.

Werner_E_0-1737313301966.png

If necessary you could add column headers

Werner_E_1-1737313440560.png

 

BTW, using the angle from the input table only makes sense, if this angle is independent from the classification in "drained"/"not drained".

If the angle depends on that classification it should not be typed in in the table but rather be calculated depending on the depth of "Bottom". Maybe like this:

Werner_E_0-1737314261298.png

 

 

 

YA_10963798
14-Alexandrite
(To:Werner_E)

Ok this is helpful. Thank you my friend

Yusra Alsabahi
Project Manager
Civil Seven
@: alsabahi@civil7.nl
m: +90-535 553 33 72
Civil7 B.V.
Stationsstraat 36A
3811MK Amersfoort www.civil7.co.uk
Announcements

Top Tags