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

Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X

Help with Programming Maximum Function

amaurer
1-Newbie

Help with Programming Maximum Function

I have a vector that represents monthly values for 30 years of data (i.e. 360 discrete values). I need to write a programming loop that finds the maximum value in each year. I'm having an issue setting up a counter on the "max" function. Any suggestions?

7 REPLIES 7
RichardJ
19-Tanzanite
(To:amaurer)

Please post a worksheet with the data and what you have so far.

A draft worksheet is attached.

RichardJ
19-Tanzanite
(To:amaurer)

It's easier to do it by splitting out each year using the submatrix function.

That worked perfectly. I have never used the submatrix command, but I will now. Thanks for your help!

After looking at other datasets, I don't think the submatrix command will work. It just so happens that the dataset that I provided had the max values in January of every year. Other datasets may not have this (i.e. the max may not occur in the same month every year). It appears that the programmer sets the increments (i.e. ir, jr, ic, jc), which returns a value specified by the increments chosen, not necessarily the maximum in each year. Am I intrepreting this correctly? If so, is there another way to calculate the maximum value in every year?

RichardJ
19-Tanzanite
(To:amaurer)

The submatrix function takes the GW vector and splits out a new vector for a given year. The max function finds the maximum value in that new vector, regardless of it's position. So yes, it will work.

MikeArmstrong
5-Regular Member
(To:amaurer)

As Richard has indicated in his worksheet you should try and post a worksheet with the problem section only. This helps other collabs get involved and take stock of the help offered by others without spending a lot of time trawling through long sheets.

Mike

http://communities.ptc.com/servlet/JiveServlet/showImage/2-149416-2532/bar_anim.gif

Top Tags