Well i have attached a .cls file.. This performs linear regression operation..
I have an array with me MyArray(,)..
Now this is a 2 D array..
Wat i need to do is i need to read from the array and have to Calculate:
log(0.931227737/MyArray(i,j)) and store this in a new array.. MyArrayX()
Similarly i got to do for each of the value in the array..
And i got to read the MyArray(,) and calculate:
log(MyArray(i,j)) and store this in new arra.. MyArrayY()..
Now for the linear regression, we need to pass the X and Y value when we call the class..
The following is the code i got from the net.. Here the class is called when we click on the form..
Instead i need to call the class when we pass each of the values in the arrays..
That is when we call the class, the x value would be MyArrayX(0,0) and the corresponding y value that is passed would be MyArrayY(0,0).. Similarly MyArrayX(1,0) etc..
VB Code:
Option Explicit
Private Type PointType
X As Double
Y As Double
End Type
Dim Reg As New RegressionObject
Const R = 100
Dim P(1 To 200) As PointType
Private Sub Form_Load()
Reg.Degree = 3
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
With Reg
.XYAdd X, Y
P(.XYCount).X = X
P(.XYCount).Y = Y
Redraw
End With
End Sub
Private Sub Redraw()
Dim i&
Cls
With Reg
For i = 1 To .XYCount
Circle (P(i).X, P(i).Y), R
Next i
CurrentX = ScaleLeft
CurrentY = .RegVal(CDbl(ScaleLeft))
For i = ScaleLeft To ScaleWidth Step R
Line -(i, .RegVal(CDbl(i))), vbBlue \ 2
Next i
End With
End Sub
Option Explicit
Private Type PointType
X As Double
Y As Double
End Type
Dim Reg As New RegressionObject
Const R = 100
Dim P(1 To 200) As PointType
Private Sub Form_Load()
Reg.Degree = 3
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
With Reg
.XYAdd X, Y
P(.XYCount).X = X
P(.XYCount).Y = Y
Redraw
End With
End Sub
Private Sub Redraw()
Dim i&
Cls
With Reg
For i = 1 To .XYCount
Circle (P(i).X, P(i).Y), R
Next i
CurrentX = ScaleLeft
CurrentY = .RegVal(CDbl(ScaleLeft))
For i = ScaleLeft To ScaleWidth Step R
Line -(i, .RegVal(CDbl(i))), vbBlue \ 2
Next i
End With
End Sub
So wat changes to be made here so that i can perform the action(call the class) wheni click a command button and pass the x and y values as i want it to...
Please help me with this..
I hope i'v made things clear.