Code to get matlab to solve for x and plug that number to the 2nd equation to find intersection point
Afficher commentaires plus anciens
Hello,
What a beautiful piece of software!.. thank you for making it! I'm trying to get some linear programming work done. and i'm having problems with finding the intersection of two equations on a plot. I have these two constraints
% X + 2Y <= 16 #Constraint 1
% 5X+ 3Y <= 45 #Constraint 2
% X, Y >= 0
My try was:
clc, clear, close all
% X + 2*Y <= 16
x = [0 16];
y = [8 0];
% 5*X2 + 3*Y2 <= 45
x2=[0 9];
y2=[15 0];
%%PLOTTING
figure; plot(x,y, 'r');
hold on
plot(x2,y2, 'b');
hold off;
title('Représentation Graphique du PL'), xlabel('x - Axe des abscisses'), ylabel('Y - Axe des Ordonnées');
legend('X+2Y<=16', '5X+3Y<=45');
TRIED THIS CODE TO SHOW THE INTERSECTION POINT, BUT DIDN'T WORK...
%method 2
%---------
% sub = find(x == y)
%
% x_intersect = y(sub);
% intersect_pt = y(sub);
%
% figure(1);
% p = plot(x,y,...
% x2,y2,...
% x_intersect, intersect_pt, 'ko');
Thanks!
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur 2-D and 3-D Plots dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!