T O P I C R E V I E W |
Gabelach |
Posted - 06/28/2013 : 5:28:31 PM Origin Ver. and Service Release (Select Help-->About Origin): OriginPro8 Operating System: win 8
Hello to everyone,
I have just started using OringPro 8 at my university for my thesis and I have been confronted by some tedious tasks. I have seen that it is possible to use labTalk for programming macros (by editing the custom.ogs file) but I'm having some issues.
My aim is to automate the process of deleting a couple hundreds useless columns form various csv files; the columns are always in the same positions, so the process should be pretty easy; This said, the problem is that I can't find a function to delete a column...
Any help would be appreciated! Thanks! |
6 L A T E S T R E P L I E S (Newest First) |
Gabelach |
Posted - 07/06/2013 : 1:04:25 PM Yes, it does come from the Origin C section. But, since the syntax seemed similar to the example you gave me before, I thought it might work.
Anyway, thank you again, I will see if I can use your last code with some minor changes (as I have found, the column not always has the minimum in zero)
Thanks! |
greg |
Posted - 07/05/2013 : 4:38:07 PM Try to keep track of where you are in the Help resources. Your example: wks.Columns(C6).SetType(OKDATAOBJ_DESIGNATION_X); // An X column looks like it came from Origin C Help documentation.
The LabTalk equivalent would be: wks.col$(colnum(C6)).type = 4;
vfind can be used to get all rows where a value of 0 exists in a column (or even all values within a certain distance from 0):
dataset dsIndexes; // Dataset to store rows where found vfind -r 0 ix:=[Book1]"Sheet1"!C6 value:=0 ox:=dsIndexes tol:=1E-2; ty -l "Zero +/- 1E-2 found in rows "; loop(ii,1,dsIndexes.GetSize()) { if(ii==1) ty -l $(dsIndexes[ii]); else ty -l ,$(dsIndexes[ii]); } type; |
Gabelach |
Posted - 07/02/2013 : 4:17:38 PM Thank you again, this works perfectly.
I was also trying to change a column attribute (from Y to X), but the command
wks.Columns(C6).SetType(OKDATAOBJ_DESIGNATION_X); // An X column
doesn't seem to work.
And I was also wondering if there is a function similar to Datasheet-FindCol which operates on columns. For example, in order to find the positions of zeroes in a column. Could I use the vfind function? I'm not sure if the returned values can be saved in order to be used later... |
greg |
Posted - 07/02/2013 : 2:30:58 PM Assuming a worksheet with two columns : A and B
lr col(B) -b 1 -e 4; // Linear fit based on first four points wks.AddCol(Fit); // Add a column for linear fit data col(fit) = lr.b * col(A) + lr.a; // Calculate wks.AddCol(Residuals); // Add a column for residuals col(Residuals) = col(B) - col(Fit); // Subtract fit from data
This is very 'old school' and we recommend using the fitlr X-Function instead.
|
Gabelach |
Posted - 07/01/2013 : 4:30:53 PM Thank you! You allowed me to save up a lot of time!
But now I would like to do something more. I have seen that via the command lr I could get the slope and intercept of the fitted data.
Is it possible to get a new column where linear fit has been subtracted? Moreover, the linear fit should be done only between the first four points (but I think I could set this with the "-b dataset" option, right?). |
greg |
Posted - 07/01/2013 : 09:50:25 AM You can delete a column by Long Name del col("Sample 3") Short Name del col(F) Index (from 1) del col(6) or use a variable when deleting by index NextCol = 6; del wcol(NextCol);
|