Question

Write a MATLAB function that takes coord natos of four points as inputs and returns the coord nates of ntersection of the linUsing MATLAB Please

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Save below code except OUTPUT as line_int.m

function [P]=line_int(P1,P2,P3,P4)

PA=[P1(1) P2(1) P3(1) P4(1)];

PB=[P1(2) P2(2) P3(2) P4(2)];

[m,b]=line_eq(PA,PB);

P=inv([-m(1) 1;-m(2) 1])*b;

function [m,b]=line_eq(PA,PB)

m1=(PB(2)-PB(1))/(PA(2)-PA(1));

b1=(PB(1)-m1*PA(1));

m2=(PB(4)-PB(3))/(PA(4)-PA(3));

b2=(PB(3)-m2*PA(3));

m=[m1 m2];

b=[b1;b2];

end

end

OUTPUT----------------------------------------------------------------------------------------------

>> line_int([-1 0], [3 6], [-2 6], [7 -3])
ans =

   1.0000
   3.0000
Add a comment
Know the answer?
Add Answer to:
Using MATLAB Please Write a MATLAB function that takes coord natos of four points as inputs and returns the coord nates of ntersection of the line passing through ooints 1 and 2 and the line passing t...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT