Prev: ginput crosshair error/bug
Next: documentation read
From: Adam Parry on 22 Jul 2010 09:46 I've just created a straight line with polyval on some data, and I was wondering whether it was possible to find the x value when the polyval becomes zero? this is what I have got A = [a1,a2]; B = [b1,b2]; p = polyfit(A,B,1); f = polyval(p,x); hold on; plot(x,f,'r'); I want x @ f = 0 I think
From: John D'Errico on 22 Jul 2010 10:09 "Adam Parry" <adam.parry-2(a)postgrad.manchester.ac.uk> wrote in message <i29i2t$nnl$1(a)fred.mathworks.com>... > I've just created a straight line with polyval on some data, and I was wondering whether it was possible to find the x value when the polyval becomes zero? > > this is what I have got > > A = [a1,a2]; > B = [b1,b2]; > > p = polyfit(A,B,1); > f = polyval(p,x); > hold on; > plot(x,f,'r'); > > I want x @ f = 0 > > I think Perhaps you wish to find a "root"? what happened when you tried lookfor root at the command line? What hints do you see when you tried help polyfit at the command line? Learn how to find what you need from the matlab help. It is all there, and in a simply accessible form. John
From: Matt J on 22 Jul 2010 10:56 "Adam Parry" <adam.parry-2(a)postgrad.manchester.ac.uk> wrote in message <i29i2t$nnl$1(a)fred.mathworks.com>... > p = polyfit(A,B,1); > f = polyval(p,x); > hold on; > plot(x,f,'r'); > > I want x @ f = 0 ========= xAtzero=-p(2)/p(1); %Assuming p(1)~=0
From: Ross on 27 Jul 2010 03:04 "Adam Parry" <adam.parry-2(a)postgrad.manchester.ac.uk> wrote in message <i29hv4$fv7$1(a)fred.mathworks.com>... > I've just created a straight line with polyval on some data, and I was wondering whether it was possible to find the x value when the polyval becomes zero? > > this is what I have got > > A = [a1,a2]; > B = [b1,b2]; > > p = polyfit(A,B,1); > f = polyval(p,x); > hold on; > plot(x,f,'r'); > > I want x @ f = 0 > > I think Take a look at the function "roots" http://www.mathworks.com/access/helpdesk/help/techdoc/ref/roots.html It returns the x values where the polynomial is zero. The roots function is mentioned at the end of the help for polyfit Ross
|
Pages: 1 Prev: ginput crosshair error/bug Next: documentation read |