02-13-2014 09:07 AM
Hi,
I am trying to copy specific data between two sets of X values (which are specified in the script) and then plot a regression curve for them.
I have managed to set the cursor values and create a band but the only way I can see of copying it is to set flags and copy the data points which cannot be done in a script (as far as I can see)
Searching on the forum suggested using the x coordinate value to find the row but the data I am using has multiple Y values at X coordinates which means this won't work as it only returns the row of the first value it finds.
Any suggestions? Copying the data to new channels would be the most useful solution but if I can calculate a regression curve between the two x values then I might be able to work with that.
Here is the code as it stands:
Dim MyFileNames, iCount, Sheet, Area, Graph, Curve, chlength Call FileNameGet("ANY", "FileRead", DataReadPath, "TDM data (*.tdm),*.tdm", "All.lst", True, "Data selection") MyFileNames = Split(FileDlgFileName,"|") For iCount = 0 To Ubound(MyFileNames) Call DataFileLoad(MyFileNames(iCount)) Next Call View.LoadLayout("view1") Set Sheet = View.Sheets(1) Set Area = Sheet.Areas(1) Area.DisplayObjType = "CurveChart2D" Set Graph = Area.DisplayObj Call Graph.Curves.RemoveAll Set Curve = Graph.Curves.Add("Y_Accel","Strg_Angle") Sheet.Cursor.Type = "Band" Sheet.Cursor.X1 = -0.1 Sheet.Cursor.X2 = 0.1 'This is where I'd like to copy the data points from flags Chlength=CL("CopyYStrg_Angle") Call ChnApprXYCalc("CopyXY_Accel", "CopyYStrg_Angle", "Y_Accel_Strg_Torq_approx", "Strg_Torq_approx", "Partition complete area", Chlength, 1) Set Sheet = View.Sheets(1) Set Area = Sheet.Areas(1) Area.DisplayObjType = "CurveChart2D" Set Graph = Area.DisplayObj Set Curve = Graph.Curves.Add("Y_Accel_Strg_Torq_approx","Strg_Torq_approx")
And the plot so you can see what I am attempting to complete (automatically though!)
Many thanks for your help
Solved! Go to Solution.
02-13-2014 04:26 PM
James,
I bet you will receive an answer from one of our AE's shortly, answering your specific question. Just out of curiosity: Is this a hysteresis curve and what you are trying to achieve is cleaning it up so that you can derive more details like slope, width etc?
02-14-2014 02:26 AM
Yep, got it in one.
Will also be using the method for other more conventional pieces of data so will be useful either way
02-14-2014 02:32 AM
I remember that one of our PSE's create an example which cleaned up noisy data from a hysteressis measurement. Not sure whether what he created would work with your data. If you're interested and willing to post an example data set, I could have check him whther it works.
Andreas
02-14-2014 03:00 AM
I've managed to clean up other data using a butterworth filter but haven't attempted it on this set yet (as I'd prefer to do it after I have selected the bits I want). Thanks for the offer though, if I get stuck I may well take you up on it
02-17-2014 06:29 AM
I've managed to do this without using flags by manually allocating the data into new channels with an if function, based on Brad's code here http://forums.ni.com/t5/DIAdem/Can-I-copy-data-points-from-a-VBScript/m-p/1048090#M11359
Just changed the if function to check if the pieces of data were between certain values rather than check if they had been flagged (couldn't get the chnflagset command to work)