| T O P I C R E V I E W |
| LucSerre |
Posted - 01/20/2005 : 10:05:19 AM I have a matrix with data as shown, where C=coords and D=data and X=blank
XCCCCCCC CDDDDDDD CDDDDDDD CDDDDDDD CDDDDDDD CDDDDDDD
I'm trying to remove all the C's and the X. In other words, bring the cell(2,2) to cell(1,1) and same with everything else in the matrix. I can do this by cutting and pasting it, but I'm trying to implement it into a Labtalk script.
Any help would be appreciated, Thanks, Luc |
| 9 L A T E S T R E P L I E S (Newest First) |
| LucSerre |
Posted - 01/20/2005 : 1:56:01 PM P is a network drive, i can't save the template in the origin folder, because i don't have access to the Origin folder, the IT dept here at work is working on that right now, so it will eventualy be saved in the origin folder.
I got it to work Mr. Mike Buess! I modified the template that I had and now it works fine! I guess I had that template messed up when I saved it. Thanks
Thanks, and THANKS! |
| Mike Buess |
Posted - 01/20/2005 : 1:49:46 PM Is P: a network or CD drive? Probably better to save the template in the Origin folder (if you have access to it).
Mike Buess Origin WebRing Member |
| LucSerre |
Posted - 01/20/2005 : 1:45:49 PM The reason I use P:/Pinacle is because i had to create my own template that contains the ascii import options in it. Like the delimiter...etc.
I've gotten the mat.w2m to work in the past, but in this script, when I call that line, it just ignores it, and does not convert anything. The next line after that closes the wks, so at the end, i'm left with just a blank matrix window.
I tried using the default template like you said, that that time, the wks DID convert to the matrix, BUT, since the default template doesn't contain my ascii import options, it didn't import the right info.
We're getting there!!
(just btw: Thanks again for helping me so much with this, I appreciate it big time!)
|
| Mike Buess |
Posted - 01/20/2005 : 1:37:51 PM I copied your script to my Origin 6.1 script window, corrected the open command and it ran fine. I found a couple more problems that didn't affect my trials but you might look into them anyway...
1. matrix is mispelled in win -t matix, but that doesn't matter since only the first letter is important... win -t M is good enough.
2. You specify a particular worksheet template (P:\pinacle). That template doesn't exist on my PC so the default template (Origin.otw) was used instead. Try using the default wks template instead of your custom template. (replace "window -t data P:\pinacle tmp;" with "window -t D;")
...BTW, the error message you saw frequently (perhaps always) appears during ASCII import and can be ignored.
Mike Buess Origin WebRing Member
Edited by - Mike Buess on 01/20/2005 1:41:24 PM |
| LucSerre |
Posted - 01/20/2005 : 1:11:49 PM Ok, the %B%A part does work, but it does the exact same thing as it did when that part was just B
With Echo=1, i get these errors when running the open line
Error:draw -n header -z set Error:draw -n header -r
Also, the mat.w2m doesn't work still.
I'm wondering how come it worked when the code was arranged the way you had it for me initialy, but now it doens't work when i integrated/modified/copied it. |
| Mike Buess |
Posted - 01/20/2005 : 1:02:44 PM The file name is saved in the string variable %A and path is %B so your open command should be this...
open -w %B%A;
Other than that I see nothing wrong with your script. If that doesn't fix it enter echo=1 in the script window, run the script again and look for error messages. (Don't forget to turn error reporting off when your done... echo=0)
Mike Buess Origin WebRing Member |
| LucSerre |
Posted - 01/20/2005 : 12:43:10 PM Ok, here is what I have now. For some reason, towards the end, the mat.w2m doesn't convert it.
window -t matix; mat.matname$=%H; // matrix name window -t data P:\pinacle tmp; fdlog.optionDlg$=IMPASCII; fdlog.usegroup(ASCII); fdlog.open(); %B=fdlog.path$; open -w B; mat.wksname$=%H; // wks name xMin = %(%H,2,1); // value in row 1, col 2 xMax = %(%H,wks.ncols,1); // row 1, last col yMin = %(%H,1,2); // row 2, col 1 get col(1) -e nrows; // wks might have excess rows yMax = %(%H,1,nrows); // last row, col 1 del col(1); // delete 1st col in wks mark -d col(1) -b 1 -e 1; // delete 1st row in wks mat.w2m(); // wks to matrix win -cd %H; // delete wks and its columns matrix -ps X xMin xMax; // set X axis coordinates of matrix matrix -ps Y yMin yMax; // set Y axis coordinates of matrix
|
| LucSerre |
Posted - 01/20/2005 : 11:47:18 AM Thanks! That worked like a charm.
I appreciate you taking the time to help me.
Luc |
| Mike Buess |
Posted - 01/20/2005 : 11:40:53 AM Hi Luc,
The easiest way in LabTalk is probably to convert to wks, delete 1st col and 1st row of wks, then convert back to matrix. Matrix must be active when you run this script.
mat.matname$=%H; // matrix name win -t D; // create wks mat.wksname$=%H; // wks name mat.m2w(); // matrix to wks del col(1); // delete 1st col in wks mark -d col(1) -b 1 -e 1; // delete 1st row in wks mat.w2m(); // wks to matrix win -cd %H; // delete wks and its columns
Note: Origin 6.0 or earlier does not support the win -cd command so you need to delete the wks and its columns separately like this...
repeat wks.ncols {del col(1)}; win -c %H;
Note2: If the coordinates are evenly spaced you can transfer them to the matrix for plotting. (The X and Y coordinates might be swapped in the following script but you can sort that out yourself.)
mat.matname$=%H; // matrix name win -t D; // create wks mat.wksname$=%H; // wks name mat.m2w(); // matrix to wks xMin = %(%H,2,1); // value in row 1, col 2 xMax = %(%H,wks.ncols,1); // row 1, last col yMin = %(%H,1,2); // row 2, col 1 get col(1) -e nrows; // wks might have excess rows yMax = %(%H,1,nrows); // last row, col 1 del col(1); // delete 1st col in wks mark -d col(1) -b 1 -e 1; // delete 1st row in wks mat.w2m(); // wks to matrix win -cd %H; // delete wks and its columns matrix -ps X xMin xMax; // set X axis coordinates of matrix matrix -ps Y yMin yMax; // set Y axis coordinates of matrix
Mike Buess Origin WebRing Member
Edited by - Mike Buess on 01/20/2005 11:43:36 AM
Edited by - Mike Buess on 01/20/2005 12:05:55 PM |
|
|