01-12-2006 09:44 PM
01-16-2006 09:10 AM
Hey Cem,
Is there an error number? I haven't had a lot of time to look into this yet but just off the top of my head it seems that one of your parameters is not declared correctly or needs to be typecast.
Regards,
01-16-2006 08:55 PM
Hello Sam,
Thank you for the reply. The error number was something like 10024(?) I found out that my problem was to do with the function definition. The function limits were not set right. When I corrected it worked. But you are right that somehow I do not define the type correctly. See the routine below:
The xData and yData are defined as variant, likewise the yFit variable. The first two are populated in a for loop, therefore they are redimensioned prior to this. On the other hand the yFit variable is filled as an array by the NonLinearFit routine. This typing works for the fit routine, but it doesn't work for the plot routine where two differently typed variables, yData and yFit are used as arguments of the Array function. In order to make this to work I used CWDSP function for the XData, yData arrays which is an overkill. What is the reasonable solution for type casting these variables? Thank you.
Cem
Private Sub cmdFit_Click()
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim NCoeff As Integer
Dim Coefficients
Dim mse
Dim yFit
Dim xData
Dim yData
Dim tArray() As Double
With sprResults
For j = 0 To 4
' xData = CWDSP1.Ramp(nPts(j), 0, 1)
' yData = CWDSP1.Ramp(nPts(j), 0, 1)
ReDim xData(0 To nPts(j) - 1)
ReDim yData(0 To nPts(j) - 1)
For i = 0 To nPts(j) - 1
xData(i) = CDbl(sTime(i))
yData(i) = CDbl(sData(i, j))
Next
fitType = j
NCoeff = 2
Coefficients = Array(CoefValues(0), CoefValues(1))
yFit = CWStat.NonLinearFit(xData, yData, Coefficients, mse, 25)
cwgPlot(j).PlotXvsY xData, CWArray.BuildArray(Array(yData, yFit))
Next
End With
End Sub