From: Adam Parry on
I've made a polyfit straight line on my data and was wondering weather p(1) was the gradient?

here is my code...

clear all;

A = uiimport;

x = A.data(:,1);
poo = A.data(:,4);
poo2 = abs(poo);
y = sqrt(poo2);

julie = plot(x,y,'o');

%selecting initial points to plot the gradient
[x2,y2]=ginput(1);
[a,b]=min((x-x2).^2+(y-y2).^2);

b = b(1);

[x3,y3]=ginput(1);
[c,d]=min((x-x3).^2+(y-y3).^2);

d = d(1);


%plotting the gradient
A = [x(b),x(d)];
B = [y(b),y(d)];

[p,s] = polyfit(A,B,1);
f = polyval(p,x);
hold on;
axis(axis);
GRAD = plot(x,f,'r');
From: John D'Errico on
"Adam Parry" <adam.parry-2(a)postgrad.manchester.ac.uk> wrote in message <i3gppv$npc$1(a)fred.mathworks.com>...
> I've made a polyfit straight line on my data and was wondering weather p(1) was the gradient?
>

p(1) is the slope of the line, if that is what you mean.
It is the coefficient of the linear term in that linear
polynomial.

John
From: Adam Parry on
what is p(2) then?

do you find the intercept at y = 0 by dividing p(2) by p(1)?
From: Adam Parry on
don't worry, i understand now