to find co-cordinate of Intersection point of line?

1 vue (au cours des 30 derniers jours)
RS
RS le 4 Avr 2013
x=[7.8 8.25 8.5];
y=[0.96 0.99 0.94];
p=polyfit(x,y,2);
f=polyval(p,x);
plot(x,y,'o',x,f,'-');
hold on;
line([7.8 8.5],[0.96 0.94]);
hold on;
line([8.25 8.25],[0 0.99]);
Now want to compute intersection point of both lines?

Réponses (1)

Walter Roberson
Walter Roberson le 4 Avr 2013
p1 = polyfit(x(1:2), y(1:2), 2);
b1 = polyval(p1, 0);
m1 = polyval(p1, 1) - b1;
p2 = polyfit(x(2:3), y(2:3), 2);
b2 = polyval(p2, 0);
m2 = polyval(p1, 1) - b2;
And now you have m1*x + b1 = m2*x + b2, so m1 * x - m2*x = b2 - b1, so (m1 - m2) * x = b2 - b1, and so x = (b2 - b1) / (m1 - m2), after which y = m1*x + b1 to find the corresponding y.
  1 commentaire
RS
RS le 6 Avr 2013
x1=7.8;
x2=8.5;
y1=0.96;
y2=0.94;
p1 = polyfit([x1 x2], [y1 y2], 2);
b1= polyval(p1,1);
m1=polyval(p1,2)-b1;
x3=8.25;
x4=8.25;
y3=0;
y4=.99;
p2 = polyfit([x3 x4], [y3 y4], 2);
b2 = polyval(p2, 1);
m2 = polyval(p2, 2) - b2;
I got x value = -1.2867; from which co-ordinate this value corresponds to? Actually I want to compute intersection of two line with respect to x=[7.8 8.25 8.5]; y=[0.96 0.99 0.94]; over which those two lines are plotted?
x=[7.8 8.25 8.5];
y=[0.96 0.99 0.94];
p=polyfit(x,y,2);
f=polyval(p,x);
plot(x,y,'o',x,f,'-');
hold on;
line([7.8 8.5],[0.96 0.94]);
hold on;
line([8.25 8.25],[0 0.99]);

Connectez-vous pour commenter.

Catégories

En savoir plus sur GPU Computing dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by