The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum
 Origin Forum
 MAX/MIN choice

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
bjorn Posted - 04/17/1999 : 7:50:00 PM
Hi,
I need to choose the highest or lowest number respectivly, from some variables (more than two). I can't find any standard function to perform this choice but to use the conditional operator: expression?var1,var2; over again!
Is there any better solution to do this if I have eg. 10 variables to choose between?

Thanks in advance,
Bjorn

8   L A T E S T    R E P L I E S    (Newest First)
Jose Posted - 10/24/2000 : 12:20:00 PM
Are there more 'easter eggs' like this in Origin 6.0? Any other functionality not documented that could be of very use, and that would make an user think about updating to 6.1 when it is not strictly necessary, as what he/she wants is already in 6.0? Does anyone knows? :-) Just as a curiosity...

j.

Jose Posted - 10/24/2000 : 8:22:00 PM
Such functions, max() and min(), seem to be included in my Origin 6.0 SR2, although not reported anywhere. They return the maximum or minimum of a list of numbers, but they don't work with datasets the way sum() or limit do. This is,

max(1,2,3,4)=;
min(1,2,3,4)=;

returns 4 and 1 respectively, but typing

max(Data1_a)=;

simply returns the first value of that dataset.

I found this just trying...

j.

Mike Buess Posted - 10/24/2000 : 8:09:00 PM
Jose,

The max() and min() functions are finally documented in Origin 6.1 and they do exactly what you describe. This is the description of max() in the Origin 6.1 LabTalk help file:

max(values)
Returns the maximum value from a set of values. Can take up to 10 arguments. For example, y=max(1,2,3,4,5,6).

-Mike

Barb Tobias Posted - 10/24/2000 : 3:40:00 PM
There are Release Notes available for each Origin patch (as well as each product release). I recommend you skim through the Release Notes when you apply a patch. Particularly, if you program with LabTalk, the Release Notes should be useful.
The min( ) and max( ) functions were documented in the Release Notes for 6.0 SR2, SR3, and SR4 - and as Mike notes, they are documented in the 6.1 LabTalk Help file.
For future Release Notes, we'll organize the LabTalk information better so that it will be easier to find LabTalk updates and changes.

Mike Buess Posted - 05/03/1999 : 7:50:00 PM
Hi Bjorn,

Ryan's suggestion might still work for you if you create the data set results={funcA,funcB,funcC}. Use sum(results) to get the maximum (as sum.max) and minimum (as sum.min) values.

If you have a lot of functions, or if you're concerned about which of them actually yield the minimum and maximum values, it would be more convenient to name them func1, func2, func3, etc., rather than funcA, funcB, funcC. The following simple script uses the limit command instead of the sum function, because it also gives the indices of the minimum and maximum data set values. I've assumed that all functions have the single independent variable, var, but you should be able to extend it to any number of variables. Note: the limit command will change the values of x and y, so be careful about using them for your variable names in this example.

/* first create a temporary data set with N elements */
N=10; /* the number of functions */
results=data(1,N);

/* now fill that data set with the function results */
var=3; /* the variable value */
for(i=1;i<=N;i++) results[i]=func$(i)(var);

/* find and report the values you want */
limit results;
del results;
type "max: func$(limit.imax)($(var))=$(limit.ymax)";
type "min: func$(limit.imin)($(var))=$(limit.ymin)";

The response in the script window should look something like this,
max: func2(3)=10
min: func9(3)=0

I hope this helps,
Mike Buess

rtoomey Posted - 05/03/1999 : 7:08:00 PM


Follow-up to Mike Buess's response to MAX/MIN choice


Mike,


Thanks for the suggestion!


Bjorn,


In the hopes of making this task easier for you in the future, I have entered a suggestion in our database to add a MAX( ) function. I have included your name and e-mail address in case the developers need to contact you for further information. However, I expect that such a new feature will not be added to our upcoming release (Origin 6.0 - due out in mid-May) since it is so close to the release date.


Sincerely,
Ryan Toomey
Technical Support Engineer
Microcal Software, Inc.



rtoomey Posted - 04/22/1999 : 7:38:00 PM


Response to MAX/MIN choice


Bjorn,


Although I am not exactly sure what you mean by variables, I can offer you a suggestion based on my current understanding of your request:


It is possible to obtain the maximum and/or minimum value of any datasets by accessing the sum.min and sum.max object properties. To do so, you must first execute the sum(dataset) function on the dataset of interest. Just to let you know, selecting Analysis:Statistics on Columns runs the sum(dataset) function automatically (on the selected dataset(s) or range of selected dataset(s)).


If this information is not what you were looking for, please reply to this post and describe your situation in more detail. Perhaps then I will understand your situation better and can offer a more appropriate solution.


Sincerely,


Ryan Toomey



bjorn Posted - 04/22/1999 : 2:32:00 PM
Hi Ryan

perhaps I was a bit unclear in my question. What I´m looking for is a method to chosse between a number of values, assigned inside a Labtalk script. Let's say that I have three functions, funcA,funcB and funcC, that is calculated in my script and I want to have the value from whichever is the highest one as an output. In basic I would do this by MAX(funcA,funcB,funcC). If I have eg. 5 functions to choose between it is not so effective to make this choice by a series of if-commands!

Regards,
Bjorn


The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000