| TUdataLSq3D | TCL UTILITIES USER MANUAL | TUdataLSq3D |
|---|
| set |
[TUdataLSq2D  |
X
Y
Z
V
|
| X | - | Input array of X values | |||||||||
| Y | - | Input array of Y values | |||||||||
| Z | - | Input array of Z values | |||||||||
| V | - | Input array of V values | |||||||||
| nP | - | The number of input (X,Y,Z,V) data values | |||||||||
| nOrder | - | The order of the fitting polynomial | |||||||||
| Mode | - | The weighting mode to use
|
|||||||||
| CoeF | - | The return fit coefficients. | |||||||||
| Var | - | Optional input which indicated if the
varience to fit should be computed and returned. Default is Yes.
|
|||||||||
| SigV | - | Optional array of weighting values to use in the fit. Used only if wMode is set to 1. |
| rV | - | This is a list containing the number of coefficients used in the fit and the varience of the fit to the data. The latter is included in the list only if Var is 1. |
Z = A(0) + A(1)*X + A(2)*Y + A(3)*Z +
A(4)*X2 + A(5)*X*Y + A(6)*X*Z + A(7)*Y2 + A(8)*Y*Z + A(9)*Z2 ...
returning the coefficients A. Both the number of coefficients and the
varience (if computed) are returned through the function.
# FIT a noisy spherical surface data set. Data is scattered about a
# surface centered on 0 with a radius of 4. Use the fit to find
# the best radius
# MAKE up the data
set nP 0
for { set I 0 } { $I < 72 } { incr I } {
set Phi [expr ($I * 4.0) / $RtoD]
for { set J 0 } { $J <= 36 } { incr J ; incr nP } {
set Theta [expr ($J * 5.0) / $RtoD]
set X($nP) [expr cos($Phi) * sin($Theta)]
set Y($nP) [expr sin($Phi) * sin($Theta)]
set Z($nP) [expr cos($Theta)]
set R [expr 4.0 + [TUdataRnd1 V 1 PN .5]]
set V($nP) [expr $R * $R]
}
}
# SOLVE for the surface
set rV [TUdataLSq3D X Y Z V $nP 2 0 A 1]
# PRINT out the data
puts stderr "Number Of Coefficients: [lindex $rV 0]"
puts stderr "Varience : [format "%.4f" [lindex $rV 1]]"
puts stderr "A(0) Const: [format "%.4f" $A(0)]"
puts stderr "A(1) X : [format "%.4f" $A(1)]"
puts stderr "A(2) Y : [format "%.4f" $A(2)]"
puts stderr "A(3) Z : [format "%.4f" $A(3)]"
puts stderr "A(4) X*X : [format "%.4f" $A(4)]"
puts stderr "A(5) X*Y : [format "%.4f" $A(5)]"
puts stderr "A(6) X*Z : [format "%.4f" $A(6)]"
puts stderr "A(7) Y*Y : [format "%.4f" $A(7)]"
puts stderr "A(8) Y*Z : [format "%.4f" $A(8)]"
puts stderr "A(9) Z*Z : [format "%.4f" $A(9)]"
# FIND the average radius of the sphere from the fit
set nC [lindex $rV 0]
set R 0.0
for { set I 0 } { $I < $nP } { incr I } {
set R [expr $R + [TUpolyExp3D $X($I) $Y($I) $Z($I) $nC A 2]]
}
puts stderr "Average Radius: [format "%.4f" [expr sqrt($R / double($nP))]]"
> Number Of Coefficients: 10
> Varience : 2.3567
> A(0) Const: -640.2834
> A(1) X : -0.0738
> A(2) Y : -0.0096
> A(3) Z : -0.0444
> A(4) X*X : 656.3884
> A(5) X*Y : -0.1245
> A(6) X*Z : -0.0950
> A(7) Y*Y : 656.7266
> A(8) Y*Z : -0.0206
> A(9) Z*Z : 656.3282
> Average Radius: 4.0202
| Sept 17, 2006 |
|---|