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

Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X

Programming problem on array

Teddy
11-Garnet

Programming problem on array

I am trying to program a series of iteration in mathcad, and i can't seem to program the part that I needed to get a good result. Can someone help me proofread my program?

 

my dependent variable is c3 = 1, 1.1, kd2 that will be programmed to 2 different set of rules, 

if c3<cbal , Fy and if c3>=cbal , (600(d-c3))/c3

 

My F(c3) and Mcr is not showing a result of array. I am confused where to put my index that will support my array function. Kindly help. Thank you.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Werner_E
24-Ruby V
(To:Teddy)

I am not sure what you are trying to achieve.

If you expect a return vector of 2601 values, you could do it that way

Werner_E_0-1685799336580.png

No need to provide the local variable c.3 as function argument.

But you let c.3 run up to kd.2=261 so the condition c.3<c.bal is always true and you get a vector with 2601 entries being all the same (F.y=275).

Is this really what you expect?

 

BTW, here is an alternate way to create a vector F, this time not using a fix step of 0.1 for c.3 but the range from 1 to kd.2 is divided into N steps

Werner_E_1-1685799775708.png

 

Or was your intention to just define functions for further usage? Then M must be a function of c.3 as well

Werner_E_2-1685800551397.png

 

View solution in original post

5 REPLIES 5
Werner_E
24-Ruby V
(To:Teddy)

I am not sure what you are trying to achieve.

If you expect a return vector of 2601 values, you could do it that way

Werner_E_0-1685799336580.png

No need to provide the local variable c.3 as function argument.

But you let c.3 run up to kd.2=261 so the condition c.3<c.bal is always true and you get a vector with 2601 entries being all the same (F.y=275).

Is this really what you expect?

 

BTW, here is an alternate way to create a vector F, this time not using a fix step of 0.1 for c.3 but the range from 1 to kd.2 is divided into N steps

Werner_E_1-1685799775708.png

 

Or was your intention to just define functions for further usage? Then M must be a function of c.3 as well

Werner_E_2-1685800551397.png

 

Teddy
11-Garnet
(To:Werner_E)

how do you put Result rows(Result)> is it (ctrl -)? 

Well, I wanted it to produce an array at my Mcr if the function goes otherwise. 

Thank you.

Werner_E
24-Ruby V
(To:Teddy)


@Teddy wrote:

how do you put Result rows(Result)> is it (ctrl -)? 

No! Its a vector index ([). This is a convenient way but only works OK if ORIGIN is at its default value 0.

The first time rows(R) returns 0 because R is not an array but a single scalar. So the first value is now saved in the first entry (#0) of the vector R.

If ORIGIN is set to another value, you would have to use  R [ ORIGIN+rows(R) instead of just R [ rows(R)

Nonetheless I would prefer the second method shown where you have more control over the number of entries in the vector and also can assure that the end value kd.2 is actually reached.

 

BTW, in your function/variable(?) M you used an undefined variable c (should it be c.3?). Prime uses its built-in constant c (speed of light) and so you get a unit mismatch error.

Once you got your calcs to work it would be a good idea to modify it to use correct units - Prime is good at dealing with units and you should take advantage of it.

In the meantime I had edited my post and attached the worksheet in Prime 6 format which seems to be the version you are using.

Teddy
11-Garnet
(To:Werner_E)

Yes, this was my intention because I am trying to study how the program will affect my moment graph if I have a value greater than cbal. 

 

Thank you for helping me program my study.

Werner_E
24-Ruby V
(To:Teddy)

Note that i changed your undefined variable c in the definition of the moment to c.3. Hope this is what it should be.

Top Tags