Here's a function for exponential decay. See if you can modify it to
work for your function.
function A = fit_exp_decay(x,y)
% initial guess
A0 = [max(y) 10];
% fit right here
A = lsqcurvefit(@myfunc,A0,x,y);
% display
plot(x,y,'o');
title(['Exponential decay fit : ' num2str(A)])
hold on
temp = min(x):(max(x)-min(x))/100:max(x);
plot(temp,myfunc(A,temp));
hold off
figure(gcf)
% fitting function
function f = myfunc(A,x)
f = A(1)*exp(-A(2)*x);
You are more likely to get useful help
by posting a new question in a new
thread.
Why does the function errorbar not do
what you want?
John
This is not correct. The argument E is a vector. The i-th
point will be plotted with errorbar E(i).
Try this: errorbar(1:10, 1:10, rand(1,10));
- Randy
y = 1 - 2 (a - 1) b x = [(a - 1)b = c] = 1 - 2 c x
reformulated:
1-y = (2x) c
if it was
y=1 + (a - 1)*
(1 + b c + b x - Sqrt[1 + b c + b x]^2 - 4b^2c x)/(2 b c)
The idea is to see weather the coefficients you are seeking could be
expressed linearly in an equation. It doeas not matter if your data
x,y are strongly non-linear (like c*sin(x^5)). Then its just a linear
least square problem.
Now c=(a-1)b, so a and b are not independent.
I just wonder what Sqrt[1 + b c + b x]^2 is meaning?
Do you mean abs(z)=sqrt(z^2)? If sqrt is inside square it is not
equal to abs(z), but=z.