I use a 3D plot VBscript component inside MathCAD 15.
This component has an input variable. When I put an array of several vectors (or matrices) as input variable all is OK (VB gets it as
Variant and I can loop over its elements).
But when the input variable is an array of only one vector (or matrix) VB gets it as
Double and the value of this double is
-1.#QNAN. So I can't use input variable for the next calculations.
Please see attached file for reference.
I got the same results as you and think this must be a bug.
I played around with it for a little while, and came up with a possible work-around:
You can force the input to be at least two elements by stacking it with another value.
Then, revise your VBscript loop to "For i=0 to UBound(M)-1"
Certainly not very elegant, but at least it works.
Following code gets M as an array of variants, but I can't extract the correct values, if case that they are there and it is not just an array of NaN's.
'// generate plot data
Dim x, y, z
M = Inputs(0).Value(0) ' this M is an array of variants
If IsArray(M) Then
For i=0 to UBound(M)
MM=M(i) ' MM is an array of variants, can check with a msgbox
x = MM ' MM(0) gives error
y = MM
z = MM
a = AddScatterPlot(x,y,z) ' just plots an isolated point.
I agree with Mark. It's a bug, and what the vbscript receives is not usable.
With the code above, VarType for M is 8204, an array of single precision floating point numbers. VarType for M2 is also 8204, but the array has a LBound and a UBound of 0, and if I try to look at M2(0) I get a subscript out of range error.