Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

CW 2.01 documentation accuracy; no examples

I'm trying to use Components Works v2.01 CWStat.StdDev, It is labeled in the help file as a Sub but looks lilke a function. I want it to compute the Standard Deviation of values in my array & need a coding example for VB6. CWStat1.Mean(array) works fine as a function.
0 Kudos
Message 1 of 3
(5,726 Views)
Hello

This is what the documentation states:

StdDev Method
Syntax
CWStat.StdDev x, MeanValue, StdDev

Purpose
Computes the standard deviation and the mean (average) values of the input array.

Parameters:
x As Variant
[Input] One-dimensional input array.

MeanValue As Variant
[Output] Mean value.

StdDev As Variant
[Output] Standard deviation.


The StdDev procedure does not return a value, so its not a function.

All you need is to pass the variables as a function parameter, and the procedure should return the mean and std deviation values in the variables.

You can copy and paste the following code inside a VB callback and see how the function works. Make sur you have a CWDSP1 and CWStat1 control dropped on the UI before runni
ng this


Dim meanv As Variant
Dim std As Variant
Const n = 1024
Dim amp As Variant, phase As Variant, cycles As Variant
Dim x As Variant
amp = 1
phase = 0
cycles = 2

x = CWDSP1.SinePattern(n, amp, phase, cycles)
CWStat1.StdDev x, meanv, std

Hope this helps

Bilal Durrani
NI
Bilal Durrani
NI
Message 2 of 3
(5,726 Views)
Very good answer - it is a "method". I tested it and the results are fast and accurate. I disagree about the documentation however. My Component Works manual (April 1998) contains only a table of Controls and "functions" of which (CWDSP) StdDev is listed as one. Nothing else about syntax and semantics. The VB HELP file is better but incorrect. It states: Sub CWStat.StdDev (x as variant, meanval as variant, sDev as variant); shows the calculation formulas and defines the parameters. There are no examples. VERY confusing at the least! Perhaps you have referred to an improved manual.

Thanks for your help. I'm not about to pay big bucks for an upgrade since I am now essentially retired...
0 Kudos
Message 3 of 3
(5,726 Views)