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

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

programming question, would like to know max value of variable when its pair is positive

JoshuaKeena
1-Newbie

programming question, would like to know max value of variable when its pair is positive

I have a programming question that I've been unable to solve.

I have a string of paired variable outputs, x and y. I would like to know what the programming lines would look like to compute the max value of x when y is positive.

At some point in the string, y goes from positive to negative, while x continues to grow. Again, I'm interested in the max value for x while y is still positive.

Thank you in advance for your assistance.

Sincererly,

Josh

1 ACCEPTED SOLUTION

Accepted Solutions

Joshua Keena wrote:

I have a programming question that I've been unable to solve.

I have a string of paired variable outputs, x and y. I would like to know what the programming lines would look like to compute the max value of x when y is positive.

At some point in the string, y goes from positive to negative, while x continues to grow. Again, I'm interested in the max value for x while y is still positive.

Do you have an example of the string that you can post? How do you separate the values (eg, comma)? Does y become positive again?

See attachment for food for thought ...

Stuart

View solution in original post

7 REPLIES 7

Joshua Keena wrote:

I have a programming question that I've been unable to solve.

I have a string of paired variable outputs, x and y. I would like to know what the programming lines would look like to compute the max value of x when y is positive.

At some point in the string, y goes from positive to negative, while x continues to grow. Again, I'm interested in the max value for x while y is still positive.

Do you have an example of the string that you can post? How do you separate the values (eg, comma)? Does y become positive again?

See attachment for food for thought ...

Stuart

Something like this (assuming that when you used the word "string" you just ment a buch of pairs of x and y and not that the form of the input was in text strings)

StuartBruff
23-Emerald II
(To:wayne)

Wayne Reid wrote:

Something like this (assuming that when you used the word "string" you just ment a buch of pairs of x and y and not that the form of the input was in text strings)

Just goes to show how careful one needs to be in interpreting statements and avoiding mind sets. I've been working on string functions both at home (updating my string library) and at work (converting registry hex(2) codes into strings). That interpretation of "string" never occurred to me!

Stuart

Wayne,

You were correct, as I misused the term 'string'. Thanks for providing a possible solution for this worksheet.

Sincerely,

Josh

As per Stuart's suggestion, I have uploaded the worksheet related to the question I posed.

As you'll see, it's a ballistic trajectory simulation.

I'm interested in figuring out when the range (x) is at a max, which occurs just prior to the elevation (y) becoming negative.

I'd like to do the same for the time of flight (t).

If the terminology I used in the original post was incorrect, please let me know that as well.

Joshua Keena wrote:

As per Stuart's suggestion, I have uploaded the worksheet related to the question I posed.

As you'll see, it's a ballistic trajectory simulation.

I'm interested in figuring out when the range (x) is at a max, which occurs just prior to the elevation (y) becoming negative.

I'd like to do the same for the time of flight (t).

OK. The easiest way to determine the x at which max height occurs is to find the max height value then use match to find its index and get the corresponding y value.

The maximum range has several possibilities. In this case, I've used a primitive zero-crossing function that notes when the y value goes negative, leaving you to pick the value before.

If the terminology I used in the original post was incorrect, please let me know that as well.

I'd have probably said 'pairs of vectors' as 'string' has another meaning in Mathcad (ie, text) ... but Wayne understood what you meant.

Stuart

Stuart,

Thanks very much for taking the time to assist with this worksheet. I sincerely appreciate it. My apologies for using incorrect terminology.

Best,

Josh

Top Tags