Reputation: 5681
I have the equation ln(c)=-1/2k^2 * z^2, where y = ln(c), x = z^2 and a = -1/2k^2.
I want to estimate the a
, so:
a = polyfit(z.^2, log(abs(c)), 1)
Because I have the (initial) equation c = exp(-z^2/2k^2), from above I am founding two values for a
and now I want to estimate k (k1), so I do:
k1 = sqrt(-1/2*a(1))
Now, I want to predict c and error using values of k1 and z. So, I do:
c_predict = polyval(a,z)
c1 = exp((-z.^2)/2*k1^2)
error = c_predict - c1
Or just:
c1 = exp((-z.^2)./2*s1^2)
error1 = c - c1
What is right?
error = c_predict - c1
or
error = c - c1
?
Upvotes: 1
Views: 5146
Reputation: 26
Try looking into the norm command:
relative least squares error = norm(y-y',2)/norm(y)
y is your original signal and y' is the signal your measuring the error of.
See here
Upvotes: 1