From: Thomas on
Hello,
for analytical data I need a linear interpolation. If I use the interp1-command I get a function with a y-value unequal zero at the point x=0 in the form y=A+Bx. But I need a function in the form y=Bx were the graph has a y-value of 0 at the x=0 without additives. What can I do here?
From: Walter Roberson on
Thomas wrote:
> Hello, for analytical data I need a linear interpolation. If I use the
> interp1-command I get a function with a y-value unequal zero at the
> point x=0 in the form y=A+Bx. But I need a function in the form y=Bx
> were the graph has a y-value of 0 at the x=0 without additives. What can
> I do here?

You should probably use the \ operator to do linear regression with 0 as
the constant term. I do not know how to set that up myself, but the
sequence has been posted several times in the past and would likely come
up if you were to search the archives for linear regression (and adding
x=0 to the search might help.)
From: John D'Errico on
Walter Roberson <roberson(a)hushmail.com> wrote in message <L2FQn.97024$304.56871(a)newsfe12.iad>...
> Thomas wrote:
> > Hello, for analytical data I need a linear interpolation. If I use the
> > interp1-command I get a function with a y-value unequal zero at the
> > point x=0 in the form y=A+Bx. But I need a function in the form y=Bx
> > were the graph has a y-value of 0 at the x=0 without additives. What can
> > I do here?
>
> You should probably use the \ operator to do linear regression with 0 as
> the constant term. I do not know how to set that up myself, but the
> sequence has been posted several times in the past and would likely come
> up if you were to search the archives for linear regression (and adding
> x=0 to the search might help.)

This is not a linear interpolation, but a linear approximation
if you use backslash.

But I'm not really sure what is the problem. Does the OP
have multiple points to which a straight line is to be fit? If
so, then use backslash. The code to do that would be simply

B = x(:)\y(:);

Now you can predict new values as y = B*x.

However, if it is a case of the use of interp1, where the curve
must pass through (0,0), then add an extra data point at (0,0).

So I don't know what the real question is here without a more
detailed explanation from the OP.

John