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
 convert worksheet to matrix 2d binning
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Baustelle

Germany
4 Posts

Posted - 08/01/2003 :  04:42:07 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
It would be great if somebody could tell me which
method I have to use (in labtalk or in Origin c) in order to activate the 2d binning tool which is normally accessible under “edit:convert to matrix”. I can not find a single example in the help files. The idea is to import an ascii file select a y-column and convert it to a matrix using 2d binning. I would also need to add matrices. I did not find a command for adding either.

I know how to import and do some basic calculations but what I desperately need is the convert worksheet to matrix using 2d binning method.

Thanks for your help

Mike Buess

USA
3037 Posts

Posted - 08/01/2003 :  07:12:00 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

Open the script window. While pressing Ctrl+Shift, select the menu command Edit->Convert to Matrix->2D Binning. This opens CodeBuilder at the script that does the work. It also types the command's menuID to the script window, so you can run the command with menu -e menuID;

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 08/01/2003 07:12:59 AM
Go to Top of Page

Baustelle

Germany
4 Posts

Posted - 08/01/2003 :  07:45:19 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank you for replying
But still this brings me only one step further
since I can not tell via the run.section command
which Y-column should be taken from my worksheet
and besides this executing "menu -e menuid"
leads to another window which asks me for the size of the bins and so on. I thought I need one of the "mat. .." methods like mat.xyztm
but just for the 2d binning. There as far as i understood you can prespecify many things like hopefully also the bin size.
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 08/01/2003 :  10:35:04 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
run.section is usually called as run.section(filename,sectionname), but when sectionname is in the same file from which the call is made filename can be omitted. The Shift+Ctrl+Select method I suggested earlier brings you to the starting script for the 2D Binning command, which is the [2DBinning] section of wks.ogs. The first if() statement in that section calls the [BinInit] section directly below in the same file where tests for column selection are handled. There are too many commands to describe, so I'll just refer you to the appropriate sections in the LabTalk Language Reference section of the programming guide...

wks.isColSel(): Object Reference->Alphabetical Listing->Wks
%(%H,...) notation: Overview->Substitution Notation->%() Substitution
exist(): Function Reference->Utility Functions->Miscellaneous Functions

After the column is determined its limits are found for use in the bin size dialog you describe...

limit: Command Reference->Alphabetical Listing->Limit
sum(): Function Reference->Statistical Functions->Statistics on Datasets->sum(dataset)

Next, the [GetLimits] section runs the binning dialog and [CreateMatrix] does the rest. So all of the commands, methods and properties that you need are in wks.ogs. Look it over and post back again if you have more questions.

Mike Buess
Origin WebRing Member
Go to Top of Page

Baustelle

Germany
4 Posts

Posted - 08/03/2003 :  1:33:58 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank you again!
Your comments were very helpfull!
But there is still one more problem.
Here is the code snippet that works so far fine for me
//////
wks.colSel(5,1);
%A=%(%H,5,);
run.section(WKS,BinInit);
limit.xmin=-100;
limit.xmax=100;
limit.ymin=-100;
limit.ymax=100;
//run.section(WKS,GetLimits);
run.section(WKS,CreateMatrix,%A);
//////////////
I don't want the GetLimits Dialog to pop out
that's why I am using the BinInit section.
BinInit finds himself the Xbin-Size/YBin-Size.
But I would like to preset it myself. Is there another
limit command like limit.Xbin or limit.xinc or something like this?
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 08/03/2003 :  3:09:04 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
First, there is no point in using the limit command if you are going to change its results (limit.xmin, limit.xmax, etc.). Since your script starts out by specifying a column there is no need to run [BinInit] at all. Second, [GetLimits] merely allows the user to adjust those values and defines XBins and YBins in terms of them, so you only need the XBins and YBins definitions from that section. You might try something like this...

//wks.colSel(5,1);
%A=%(%H,5);
//run.section(WKS,BinInit);
limit.xmin=-100;
limit.xmax=100;
limit.ymin=-100;
limit.ymax=100;
xinc=1; yinc=1; // you might want to give these your own values too
//run.section(WKS,GetLimits);
//The next four lines are all we need from GetLimits
XBins=(limit.xmax-limit.xmin)/xinc;
YBins=(limit.ymax-limit.ymin)/yinc;
if(int(YBins)!=$(YBins)) YBins+=1;
if(int(XBins)!=$(XBins)) XBins+=1;
run.section(WKS,CreateMatrix,%A);
run.section(WKS,Cleanup); //clean up datasets and variables

I hope that helps.

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 08/03/2003 3:12:25 PM

Edited by - Mike Buess on 08/03/2003 3:37:55 PM
Go to Top of Page

Baustelle

Germany
4 Posts

Posted - 08/04/2003 :  2:36:46 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Everything is working fine :-)
Thank you very much!!
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