Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Curve fitting

0 views
Skip to first unread message

Evangelos Evangelos

unread,
Aug 16, 2006, 6:25:54 PM8/16/06
to
I have some data (for an x value I have a y value). I plot x,y.
However, I want to fit in them data on equation like
y=a*x/(1+a*x).I know that there is polyfit qubic,etc. However, I
don't know how I can implement my equation. Does someone know? Could
someone to help me?
Thanks.

spasmous

unread,
Aug 16, 2006, 7:50:25 PM8/16/06
to

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);

Evangelos Evangelou

unread,
Aug 29, 2006, 10:05:17 AM8/29/06
to
Hi to everyone,
I have some points and one curve that fit in the points. However, for
each point I have estimated the error. My problem is that I need to
present the errorbar for each point. If the points had the same error
then it would be too easy drawing the error bar but now I can find
something.
Is there any idea?
Thanks a lot.

John D'Errico

unread,
Aug 29, 2006, 10:46:51 AM8/29/06
to

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

Evangelos

unread,
Aug 29, 2006, 1:17:53 PM8/29/06
to
I don't think so.
The errobar can plot the errorbars but only if I have the same error
for each point.

Randy Poe

unread,
Aug 29, 2006, 1:30:36 PM8/29/06
to

Evangelos wrote:
> I don't think so.
> The errobar can plot the errorbars but only if I have the same error
> for each point.

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

Per S

unread,
Aug 29, 2006, 1:31:02 PM8/29/06
to
Using Mathematica to simplify your equation I get

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.

0 new messages