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
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Find minimum in dataset
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

amorris

Canada
Posts

Posted - 03/10/2006 :  4:53:35 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): 7.5sr6
Operating System:winXP

Hi everyone,

I Could anyone tell me what's the easiest way to find the minimum value in a data set? One way to do this would be to sort the data set in ascending order and then take the first element. Are there other ways?

Here's why I'm asking. I am calculating a series of energy spectra (basically, just a scatter plot with lots of points in it) which appearance depends on a parameter that I can change. To visualise the effect of this change, I am making an animation of successive spectra by exporting individual frames as gif files and subsequently combining them all together to make an animated gif. What I am looking for in this animation is to see where the lowest energy state goes as I change my parameter. In other words, for each frame I want to find the data point (x,y) which has the lowest y value, and then mark it somehow so that in my animation it would be easy to follow this state.

So here's what I need to find out

1) Fastest way to identify this lowest lying (x,y) data point
2) How to make this single point a different color, or size, or something. My data is just arranged in one x and one 1 column. It would be nice if I could automatically make origin draw an arrow pointing to this data point, but this seems really complicated...


Thanks for any suggestions,

Sincerely
Alexis

easwar

USA
1965 Posts

Posted - 03/10/2006 :  5:19:08 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Alexis,

I presume you are working with one worksheet and changing the data in that worksheet and then want to cycle thru various frames?

You could try the following:
1> Plot your data in a graph
2> Add an arrow object (use Tools toolbar button and draw). Position the start end of the arrow at some point that you desire, which can stay constant for each frame for example. Such objects have a name and associated properties such as start, end coordinates. The default arrow object has name "arrow".
3> Then run the following script in script window (copy and paste all lines and highlight them all and hit Enter):


// Script starts here----
// %c points to active data plot
// Get the X dataset name into %a
%a=xof(%c);
// Use the limit command to find min in y and index (row)
// where min occurs
limit %c;
i = limit.imin;
// Get xmin and ymin
xmin = %a(i);
ymin = limit.ymin;
// type message
type Minimum of %c is at: ( $(xmin), $(ymin) );
// Presume there is an arrow object with name "arrow"
// Position end of arrow at xmin, ymin
arrow.x2 = xmin;
arrow.y2 = ymin;
// Script ends here


What this will do is to find the xmin, ymin and report that to script window, and then also position the head of the arrow right at this coordinate point.

You could then put the above code inside a loop and then keep changing your data in the worksheet and the arrow will point to the new lowest point. Just keep graph active and change data in worksheet.

You may also want to look at this file exchange tool that can help with making the animatied GIF:
http://www.originlab.com/fileexchange/details.aspx?fid=122

Easwar
OriginLab



Edited by - easwar on 03/10/2006 5:24:17 PM
Go to Top of Page

amorris

Canada
Posts

Posted - 03/10/2006 :  5:37:57 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks easwar, that was extremely helpful :). I'll let you know if I have any further problems,

Alexis
Go to Top of Page

amorris

Canada
Posts

Posted - 04/17/2006 :  8:03:43 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Easwar,

You're little code works perfectly... However, do you know how to automatically create an arrow without any user input? I've searched the help files, and all that I can find relates to allready created ("named") objects.

Thanks!
Go to Top of Page

easwar

USA
1965 Posts

Posted - 04/17/2006 :  9:42:00 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Alexis,

The following script code basically draws a line segment from (1,2) to
(5,6) and turns on the end arrow property of that line. The line is given a custom name of "myarrow".

Easwar
OriginLab



draw -n myarrow -l {1,2,5,6};
myarrow.color=2;
myarrow.linewidth=3;
myarrow.arrowbeginshape=0;
myarrow.arrowendshape=2;
myarrow.arrowposition=2;
myarrow.arrowendlength=10;
myarrow.arrowendwidth=10;



Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000