How to plot 2 lines and find the coordinates of their intersection? (2024)

407 Ansichten (letzte 30 Tage)

Ältere Kommentare anzeigen

Swati Umamaheshwaran am 17 Sep. 2017

  • Verknüpfen

    Direkter Link zu dieser Frage

    https://de.mathworks.com/matlabcentral/answers/357026-how-to-plot-2-lines-and-find-the-coordinates-of-their-intersection

  • Verknüpfen

    Direkter Link zu dieser Frage

    https://de.mathworks.com/matlabcentral/answers/357026-how-to-plot-2-lines-and-find-the-coordinates-of-their-intersection

Beantwortet: Preetham Manjunatha am 8 Feb. 2022

I need to plot the lines x+y=3 and x-y= -1 and find their point of intersection. I know that to plot the lines I could use 'fplot'. How can I find the coordinates of their intersection and plot it? Please help.

0 Kommentare

-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

Melden Sie sich an, um diese Frage zu beantworten.

Antworten (5)

Star Strider am 17 Sep. 2017

  • Verknüpfen

    Direkter Link zu dieser Antwort

    https://de.mathworks.com/matlabcentral/answers/357026-how-to-plot-2-lines-and-find-the-coordinates-of-their-intersection#answer_281936

  • Verknüpfen

    Direkter Link zu dieser Antwort

    https://de.mathworks.com/matlabcentral/answers/357026-how-to-plot-2-lines-and-find-the-coordinates-of-their-intersection#answer_281936

In MATLAB Online öffnen

Another approach:

xymtx = [1 1; 1 -1];

cv = [3; -1];

xy = xymtx\cv; % Calculate Intercept

xint = xy(2); % X-Value Of Intercept

yint = xy(1); % Y-Value Of Intercept

xyind = [xint - 1, xint + 1]'; % X-Values For Plot

xydep = [cv -xyind.*xymtx(:,2)]; % Y-Values For Plot

figure(1)

plot(xyind, xydep(1,:), xyind, xydep(2,:), '-r')

hold on

plot(xint, yint, 'pg', 'MarkerFaceColor','g', 'MarkerSize',10)

hold off

This is straightforward and relatively simple linear algebra. The ‘xydep’ variable calculates the y-values corresponding to the arbitrary values in ‘xydep’, and is the result of solving ‘[X + Y] = C’ for ‘Y’.

0 Kommentare

-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

Tutku Oztel am 9 Jan. 2019

  • Verknüpfen

    Direkter Link zu dieser Antwort

    https://de.mathworks.com/matlabcentral/answers/357026-how-to-plot-2-lines-and-find-the-coordinates-of-their-intersection#answer_355748

  • Verknüpfen

    Direkter Link zu dieser Antwort

    https://de.mathworks.com/matlabcentral/answers/357026-how-to-plot-2-lines-and-find-the-coordinates-of-their-intersection#answer_355748

In MATLAB Online öffnen

Hello,

I'm sharing the function that I wrote to find the intersection points of two lines with their given slope and constant values:

function [x0 y0] = intersectPoints(m1,m2,b1,b2)

% Insersection point of two lines with known slope and constant

% parameters.

% [x0 y0] = intersectPoints(m1,m2,b1,b1)

% where m's are slope, and b's are constants.

% written by Tutku Öztel in 06.01.2019

x0 = (b2-b1)/(m1-m2); %find the x point

y0 = m1*x0+b1;

end

Late though, but still.. Hope it will be helpful! :)

Tutku

2 Kommentare

Keine anzeigenKeine ausblenden

José Luis Sandoval am 7 Jun. 2020

Direkter Link zu diesem Kommentar

https://de.mathworks.com/matlabcentral/answers/357026-how-to-plot-2-lines-and-find-the-coordinates-of-their-intersection#comment_887846

  • Verknüpfen

    Direkter Link zu diesem Kommentar

    https://de.mathworks.com/matlabcentral/answers/357026-how-to-plot-2-lines-and-find-the-coordinates-of-their-intersection#comment_887846

Usefuil, thanks.

Wai Keong Bryce Wong am 12 Okt. 2020

Direkter Link zu diesem Kommentar

https://de.mathworks.com/matlabcentral/answers/357026-how-to-plot-2-lines-and-find-the-coordinates-of-their-intersection#comment_1052126

  • Verknüpfen

    Direkter Link zu diesem Kommentar

    https://de.mathworks.com/matlabcentral/answers/357026-how-to-plot-2-lines-and-find-the-coordinates-of-their-intersection#comment_1052126

This is super useful. Thanks for your help!

Melden Sie sich an, um zu kommentieren.

Simon Kölbl am 17 Sep. 2017

  • Verknüpfen

    Direkter Link zu dieser Antwort

    https://de.mathworks.com/matlabcentral/answers/357026-how-to-plot-2-lines-and-find-the-coordinates-of-their-intersection#answer_281915

  • Verknüpfen

    Direkter Link zu dieser Antwort

    https://de.mathworks.com/matlabcentral/answers/357026-how-to-plot-2-lines-and-find-the-coordinates-of-their-intersection#answer_281915

In MATLAB Online öffnen

I would do it like this:

% define x Axis and evaluate functions

x_points = -5:0.1:5;

function1 = -x+1;

function2 = x+1;

index_intersection = find(function1 == function2);

x_value_intersection = x_points(index_intersection);

y_value_intersection = function1(index_intersection);

% plot functions and intersection point:

curve1 = plot(x_points, function1);

hold on

curve2 = plot(x_points, function2);

intersection = plot(x_value_intersection, y_value_intersection,...

'Marker', '+', 'MarkerSize', 6, 'Color', 'r');

2 Kommentare

Keine anzeigenKeine ausblenden

Cyril Okhio am 13 Nov. 2018

Direkter Link zu diesem Kommentar

https://de.mathworks.com/matlabcentral/answers/357026-how-to-plot-2-lines-and-find-the-coordinates-of-their-intersection#comment_636946

  • Verknüpfen

    Direkter Link zu diesem Kommentar

    https://de.mathworks.com/matlabcentral/answers/357026-how-to-plot-2-lines-and-find-the-coordinates-of-their-intersection#comment_636946

Sorry it did not work. There are errors in Line 9.

Image Analyst am 5 Jun. 2021

Direkter Link zu diesem Kommentar

https://de.mathworks.com/matlabcentral/answers/357026-how-to-plot-2-lines-and-find-the-coordinates-of-their-intersection#comment_1565965

  • Verknüpfen

    Direkter Link zu diesem Kommentar

    https://de.mathworks.com/matlabcentral/answers/357026-how-to-plot-2-lines-and-find-the-coordinates-of-their-intersection#comment_1565965

In MATLAB Online öffnen

@Cyril Okhio, I think @Simon Kölbl meant this:

clc;% Clear command window.

fprintf('Running %s.m ...\n', mfilename);

clear;% Delete all variables.

close all;% Close all figure windows except those created by imtool.

workspace;% Make sure the workspace panel is showing.

% Define x Axis and evaluate functions

x_points = -5:0.1:5;

function1 = -x_points+1;

function2 = x_points+1;

index_intersection = find(function1 == function2);

x_value_intersection = x_points(index_intersection)

y_value_intersection = function1(index_intersection)

% Plot functions and intersection point:

curve1 = plot(x_points, function1);

hold on

curve2 = plot(x_points, function2);

intersection = plot(x_value_intersection, y_value_intersection,...

'Marker', '+', 'MarkerSize', 20, 'Color', 'r', 'LineWidth', 2);

grid on

caption = sprintf('At intersection, x = %f, y = %f', x_value_intersection, y_value_intersection);

fontSize = 15;

title(caption, 'FontSize', 15);

xlabel('x', 'FontSize', 15);

ylabel('y', 'FontSize', 15);

fprintf('Done running %s.m\n', mfilename);

How to plot 2 lines and find the coordinates of their intersection? (9)

Melden Sie sich an, um zu kommentieren.

Matt J am 5 Jun. 2021

  • Verknüpfen

    Direkter Link zu dieser Antwort

    https://de.mathworks.com/matlabcentral/answers/357026-how-to-plot-2-lines-and-find-the-coordinates-of-their-intersection#answer_717645

  • Verknüpfen

    Direkter Link zu dieser Antwort

    https://de.mathworks.com/matlabcentral/answers/357026-how-to-plot-2-lines-and-find-the-coordinates-of-their-intersection#answer_717645

Bearbeitet: Matt J am 5 Jun. 2021

In MATLAB Online öffnen

Using this File Exchange submission,

https://www.mathworks.com/matlabcentral/fileexchange/93470-intersections-of-multiple-2d-lines-or-line-segments

xy=linexlines2D( [1,1,-3].' , [1,-1,1] ); %the intersection point

hold on

fimplicit(@(x,y) x+y-3);

fimplicit(@(x,y) x-y+1);

plot(xy(1),xy(2),'or','MarkerFaceColor','r')

hold off

How to plot 2 lines and find the coordinates of their intersection? (11)

0 Kommentare

-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

Preetham Manjunatha am 8 Feb. 2022

  • Verknüpfen

    Direkter Link zu dieser Antwort

    https://de.mathworks.com/matlabcentral/answers/357026-how-to-plot-2-lines-and-find-the-coordinates-of-their-intersection#answer_891390

  • Verknüpfen

    Direkter Link zu dieser Antwort

    https://de.mathworks.com/matlabcentral/answers/357026-how-to-plot-2-lines-and-find-the-coordinates-of-their-intersection#answer_891390

Here is the link to find the intersection point of two line segments/lines. A fast two line intersection point finder based on the line parametric space. Finds the intersection point between two lines if it exists or else submits NaN. if you need to find the intersection of the multiple line segments, MATLAB's Mapping Toolbox has function polyxpoly - that finds the intersection points for lines or polygon edges.

0 Kommentare

-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

Melden Sie sich an, um diese Frage zu beantworten.

Siehe auch

Kategorien

MATLABGraphicsGraphics ObjectsGraphics Object Properties

Mehr zu Graphics Object Properties finden Sie in Help Center und File Exchange

Tags

  • intersection of 2 lines

Community Treasure Hunt

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

Start Hunting!

Es ist ein Fehler aufgetreten

Da Änderungen an der Seite vorgenommen wurden, kann diese Aktion nicht abgeschlossen werden. Laden Sie die Seite neu, um sie im aktualisierten Zustand anzuzeigen.


Translated by How to plot 2 lines and find the coordinates of their intersection? (13)

How to plot 2 lines and find the coordinates of their intersection? (14)

Website auswählen

Wählen Sie eine Website aus, um übersetzte Inhalte (sofern verfügbar) sowie lokale Veranstaltungen und Angebote anzuzeigen. Auf der Grundlage Ihres Standorts empfehlen wir Ihnen die folgende Auswahl: .

Sie können auch eine Website aus der folgenden Liste auswählen:

Amerika

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europa

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom(English)

Asien-Pazifik

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
  • 日本Japanese (日本語)
  • 한국Korean (한국어)

Kontakt zu Ihrer lokalen Niederlassung

How to plot 2 lines and find the coordinates of their intersection? (2024)

FAQs

How to find the coordinates of the point of intersection of 2 straight lines? ›

The point of intersection formula is used to find the point of intersection of the two lines, that is the meeting point of two lines. These two lines can be represented by the equation a1x+b1y+c1=0 and a2x+b2y+c2=0, respectively. It is possible to find point of intersection of three or more lines.

How do you find the coordinate where two lines intersect? ›

To algebraically find the intersection of two straight lines, write the equation for each line with y on the left side. Next, write down the right sides of the equation so that they are equal to each other and solve for x.

How do you find the equation of intersection of two lines? ›

Point of intersection means the point at which two lines intersect. These two lines are represented by the equation a1x + b1y + c1= 0 and a2x + b2y + c2 = 0, respectively. Given figure illustrate the point of intersection of two lines.

What is the formula for coordinates of point of intersection of two lines? ›

Properties of Intersection of Sets
LawRule of Intersection
Commutative LawA ∩ B = B ∩ A
Associative Law(A ∩ B) ∩ C = A ∩ (B ∩ C)
Law of ϕ and Uϕ ∩ A = ϕ, U ∩ A= A
Idempotent LawA ∩ A = A
1 more row

How to find the intersection of two graphs? ›

The Intersection Between Two Graphs

You find the point where the graph of f and the graph of g intersects by solving the equation f ( x ) = g ( x ) . Insert x into f ( x ) = − x − 1 because it's the simpler expression of the two. You could also insert x into g ( x ) , but it would be more work.

What forms when 2 lines intersect? ›

When two lines intersect, they create vertical angles, sometimes called opposite angles, that are congruent.

How to find the intersection of two sets? ›

Step 1: Determine all of the elements in the first set. Step 2: Determine all of the elements in the second set. Step 3: The intersection is formed by including all of the elements that appear in both Step 1 and Step 2.

How to find the intersection of two lines vectors? ›

To find the point of intersection of these two lines, we must find a point P that lies on both lines. At the point of intersection the coordinates for L1 will equal the coordinates for L2. This means there exist values of s and t such that the x, y and z coordinates of the two lines are equal.

How do you find the coordinates of intersection of two functions? ›

Here's a step-by-step process:
  1. Write down the equations of the two functions, f(x) and g(x).
  2. Set the two functions equal to each other: f(x) = g(x).
  3. Solve the equation for x. ...
  4. For each x-value found in step 3, plug it back into either f(x) or g(x) to find the corresponding y-value.

What is the intersection of 2 lines called? ›

The intersection of two lines is called the point of intersection. Since lines are straight figures, a line may only cross another line at one single point.

What is the formula for coordinate geometry? ›

The straight line equation,y = mx + c, is an important formula in coordinate geometry. The slope is m, and the y-intercept is c tan θ = m, where x is the positive axis). Ans. The point on the x axis is written first, followed by the point on the y axis in coordinates written as (x, y).

How do you find the point on the intersection line of two planes? ›

To find a point on the line, you set one of the coordinates in the equations of both planes equal to zero and solve the system of equations you end up with. Note! If you set z = 0 and the line of intersection is perpendicular to the z -axis, no points on the line have z = 0 .

How to find the coordinates of the point of intersection of two functions? ›

Here's a step-by-step process:
  1. Write down the equations of the two functions, f(x) and g(x).
  2. Set the two functions equal to each other: f(x) = g(x).
  3. Solve the equation for x. ...
  4. For each x-value found in step 3, plug it back into either f(x) or g(x) to find the corresponding y-value.

How to find point of intersection of two lines vectors? ›

To find the point of intersection of these two lines, we must find a point P that lies on both lines. At the point of intersection the coordinates for L1 will equal the coordinates for L2. This means there exist values of s and t such that the x, y and z coordinates of the two lines are equal.

Top Articles
Vschsd Portal
Dragons among Oakland County softball teams with high aspirations
Poe T4 Aisling
Dunhams Treestands
Encore Atlanta Cheer Competition
Katie Pavlich Bikini Photos
Davita Internet
Is Sam's Club Plus worth it? What to know about the premium warehouse membership before you sign up
Ingles Weekly Ad Lilburn Ga
5 Bijwerkingen van zwemmen in een zwembad met te veel chloor - Bereik uw gezondheidsdoelen met praktische hulpmiddelen voor eten en fitness, deskundige bronnen en een betrokken gemeenschap.
Words From Cactusi
Cvs Devoted Catalog
Horned Stone Skull Cozy Grove
Obituary Times Herald Record
Raleigh Craigs List
Classic Lotto Payout Calculator
The ULTIMATE 2023 Sedona Vortex Guide
Nba Rotogrinders Starting Lineups
10-Day Weather Forecast for Florence, AL - The Weather Channel | weather.com
Dignity Nfuse
Boston Gang Map
Virginia New Year's Millionaire Raffle 2022
White Pages Corpus Christi
Scream Queens Parents Guide
Governor Brown Signs Legislation Supporting California Legislative Women's Caucus Priorities
Pirates Of The Caribbean 1 123Movies
Magic Seaweed Daytona
Sadie Sink Reveals She Struggles With Imposter Syndrome
The Collective - Upscale Downtown Milwaukee Hair Salon
Gopher Carts Pensacola Beach
Taylored Services Hardeeville Sc
Askhistorians Book List
Bfri Forum
Garrison Blacksmith's Bench
Skroch Funeral Home
R&J Travel And Tours Calendar
Bismarck Mandan Mugshots
KM to M (Kilometer to Meter) Converter, 1 km is 1000 m
Can You Buy Pedialyte On Food Stamps
Hellgirl000
Legit Ticket Sites - Seatgeek vs Stubhub [Fees, Customer Service, Security]
Craigslist Freeport Illinois
Cpmc Mission Bernal Campus & Orthopedic Institute Photos
Wunderground Orlando
Giovanna Ewbank Nua
Tricia Vacanti Obituary
The Great Brian Last
Best Haircut Shop Near Me
American Bully Puppies for Sale | Lancaster Puppies
The Many Faces of the Craigslist Killer
Greg Steube Height
Convert Celsius to Kelvin
Latest Posts
Article information

Author: Golda Nolan II

Last Updated:

Views: 6174

Rating: 4.8 / 5 (58 voted)

Reviews: 81% of readers found this page helpful

Author information

Name: Golda Nolan II

Birthday: 1998-05-14

Address: Suite 369 9754 Roberts Pines, West Benitaburgh, NM 69180-7958

Phone: +522993866487

Job: Sales Executive

Hobby: Worldbuilding, Shopping, Quilting, Cooking, Homebrewing, Leather crafting, Pet

Introduction: My name is Golda Nolan II, I am a thoughtful, clever, cute, jolly, brave, powerful, splendid person who loves writing and wants to share my knowledge and understanding with you.