DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

NoValue Handling

Solved!
Go to solution

I am fairly new to VBS and having some difficulties coming up with a solution. I have a sine wave I need to do some calculations on. I need to cut a window each cycle at +-1000N. Than calculate linear regression on each of those sections. Than average the positive/negative slopes. In the end I am looking to produce 2 plots one for positive and one for negative. So far I have been able to cut the data and insert NoValues. I am looking for help running linear regression on each section of data between the NoValues.

 

Dim oChn,K,currentValue, lastValue,i

Call Calculate("Ch(""[1]/Total"")=Ch(""[1]/Filtered_Total_TR_Load"")+CTNV(Ch(""[1]/Filtered_Total_TR_Load"")>1000)",NULL,NULL,"")
Call Calculate("Ch(""[1]/Total"")=Ch(""[1]/Total"")+CTNV(Ch(""[1]/Filtered_Total_TR_Load"")<-1000)",NULL,NULL,"")

lastValue = 0

Set oChn = data.GetChannel("Total")

 

For K = 1 To oChn.Size
currentValue = oChn(K)

 

If (IsNull(currentValue)) Then
oChn(K) = lastValue

 

Else
lastValue = currentValue

 

End If

 

Next

 

 

0 Kudos
Message 1 of 2
(4,033 Views)
Solution
Accepted by topic author mindmaster54

Hi mindmaster,

 

What version of DIAdem are you using?  If you happen to have DIAdem 2015, then you can use the new ChnEvent...() functions to find the row ranges of all your positive and negative slopes.  From there you can loop over each one, extracting that row range to a new channel and running the linear regression function from the ANALYSIS panel on that extracted subset to derive the slope of that cycle.  You can then save the slope values into new "Cycle Number", "Positive Slope", and "Negative Slope" channels, which you can then average over all cycles.

 

Even if you have DIAdem 2014, I can show you the hidden pre-release version of the ChnEvent...() functions that will enable the first step of the above analysis.  If you have an even older version of DIAdem, you will need to use the ChnFind() function in a loop to determine the row ranges of each cycle's positive and negative slopes.

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

Message 2 of 2
(4,002 Views)