Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

Example of use of decimate function?

Are there any examples of the decimate function from the cwdsp control anywhere?
Or any more detailed help on how to use it or what it does?
I seem to be having a a lot of problems with it.
 
TIA
 
Paul
0 Kudos
Message 1 of 4
(8,251 Views)
Although I have no experience with this particular control, I've found the following which hopefully may be of use:

An example that uses CWDSP:

http://sine.ni.com/apps/we/niepd_web_display.display_epd4?p_guid=CC109B5C131633FEE034080020E74861&p_node=DZ52130

http://sine.ni.com/apps/we/niepd_web_display.display_epd4?p_guid=B45EACE3EEA756A4E034080020E74861&p_node=DZ52006&p_source=External

Have you had a detailed look at the documentation in C:\Program Files\National Instruments\MeasurementStudio\Help\cwanalysis.chm

It might be worth posting more info on the type of problems that you are encountering, as well as a description of what you are trying to achieve with the decimate function. It would be handy if you could post your code or at least describe how you are using this function and the parameter values etc.

Thanks,

Stuart
0 Kudos
Message 2 of 4
(8,231 Views)

My first problem was just in the general use of the control,
I was expecting it to do an "in place" decimation on the
input parameter, rather than giving the data back as the 
return val.
I know I should have read the help more closely,  but a
1 line example of its usage would have made things
immediately more clear.

Subsequent problem was that it keeps failing with an out
of memory error "Runtime error 61706: Insufficient memory
to perform operation", even though there is free memory available
on the PC and I can create a new variable of the same size
with out problem. Code below

Any ideas what I'm doing wrong or just a limit on VB or the controls?

Paul

 

Option Explicit

Const cBigArraySize As Long = 60000000
Const cSmallArraySize As Long = 30000000
Dim gIntegerArray(cBigArraySize) As Long


Private Sub Command1_Click()

 Dim TempArray() As Long
 
' TempArray = CWDSP1.Decimate(gIntegerArray, 2, 1)  
<-This call always fails
 
 Dim LoopCounter As Long
 Dim TempArrayIndex As Long
 
 ReDim TempArray(cSmallArraySize) As Long <-though this always succeeds!
 TempArrayIndex = 0
 For LoopCounter = 0 To cBigArraySize Step 2
    TempArray(TempArrayIndex) = gIntegerArray(LoopCounter)
    TempArrayIndex = TempArrayIndex + 1
 Next LoopCounter
 
 
 
 Debug.Print "IntegerArray(0) = " & gIntegerArray(0) & " a(0) = " & TempArray(0)
 Debug.Print "IntegerArray(0) = " & gIntegerArray(cBigArraySize) & " a(0) = " & TempArray(cSmallArraySize)
End Sub

Private Sub Form_Load()
    Dim LoopCounter As Long
   
    For LoopCounter = 0 To cBigArraySize
        gIntegerArray(LoopCounter) = Rnd() * 100
    Next LoopCounter
   
End Sub

0 Kudos
Message 3 of 4
(8,218 Views)
I have experimentally installed, that cBigArraySize can be maximum 36782072.
TempArray should be Variant.
 
It works:
Option Explicit
Const cBigArraySize As Long = 36782072 '60000000
Private Sub Command1_Click()
'    Dim TempArray() As Long
    Dim TempArray As Variant
    TempArray = CWDSP1.Decimate(gIntegerArray, 2, 1)
    Debug.Print "IntegerArray(0) = " & gIntegerArray(0) & " a(0) = " & TempArray(0)
    Debug.Print "IntegerArray(0) = " & gIntegerArray(cBigArraySize) & " a(0) = " & TempArray(UBound(TempArray))
0 Kudos
Message 4 of 4
(8,217 Views)