Question

Consider two lines y = m1x + b1 and y = m2x + b2. To solve...

Consider two lines y = m1x + b1 and y = m2x + b2. To solve for the intersection point (x ∗ , y∗ ) of these lines (assuming they aren’t parallel) we have m1x ∗ + b1 = m2x ∗ + b2 (m1 − m2) x ∗ = b2 − b1 x ∗ = b2 − b1 m1 − m2 and thus y ∗ = m1x ∗ + b1. Using MATLAB or Octave, Write a script that prompts the user for the slopes and y-intercepts of the two lines (namely m1, m2, b1, and b2), storing each in a variable. You may assume the user does not specify parallel lines. The script should then calculate the intersection point of the lines, saving each co-ordinate to a variable, and print the result. Sample output: Enter value for m1: -3 Enter value for b1: 6 Enter value for m2: 1.5 Enter value for b2: -5.1 Lines y = -3.00 x + 6.00 and y = 1.50 x + -5.10 intersect at ( 2.47, -1.40 ) September 4, 2019 2 of 6 MAT 2010L: Lab Assignment 2 Enter value for m1: 1.2345 Enter value for b1: 10.25 Enter value for m2: 20.275 Enter value for b2: -6 Lines y = 1.23 x + 10.25 and y = 20.27 x + -6.00 intersect at ( 0.85, 11.30 )

Homework Answers

Answer #1

Please give a thumb up, thanks

codE

function Calculateintersect()
m1=input('Enter value for m1: ');
b1=input('Enter value for b1: ');
m2=input('Enter value for m2: ');
b2=input('Enter value for b2: ');
x=(b2-b1)/(m1-m2);
y=m1*x+b1;
fprintf("Lines y= %f x + %f and y= %f x + %f intersects at point (%f , %f)\n",m1,b1,m2,b2,x,y);
end

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT