help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Matching Equation to Data [solved]


From: Thomas D. Dean
Subject: Re: Matching Equation to Data [solved]
Date: Sat, 16 Mar 2013 02:39:15 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130221 Thunderbird/17.0.3

On 03/15/13 15:05, Thomas D. Dean wrote:
On 03/15/13 04:25, Juan Pablo Carbajal wrote:

data is a matrix of n x 7, [et, x, y, z, dx, dy, dz]
#################################################
## fit a plane to the data
##
## equation of plane = a*x + b*y + c*z + d = 0
## or
##       a*x + b*y + d
## z = - -------------
##            c
##
## let  f=-a/c, g=-b/c, h=-d/c
##
## z = f*x + g*y + h
##
## which is of form Ax=B
## A=[x,y,1] from data, B=[z] from data and x=[f, g, h]
##
nValues=365*2+1
data=solarsystem('/usr/local/share/ephemeris/jpleph.405',3, nValues);
## data = [et, x, y, z, dx, dy, dz]
A=[data(:,2:3), ones(size(data,1),1)]; B=data(:,4);
p=LinearRegression(A,B);
## [f, g, h]
## f=-9.4383e-06, g=4.3350e-01, h=-4.2127e+03
## and, we have
##
## z = p(1)*x + p(2)*y + p(3)
##
## p(1)*x + p(2)*y - z + p(3)
##
## let
a=p(1); b=p(2); c=-1; d=p(3);
##
## The resudual should be 0 if have a perfect match
residual=[data(:,2:4), ones(size(data,1),1)]*[a,b,c,d]'
max(abs(residual ./ data(:,2:4)))
0.0050631   0.0026610   0.0060956

Tom Dean


reply via email to

[Prev in Thread] Current Thread [Next in Thread]