Plot 3d to find point of intersection?
Show older comments
Hello
I am trying to find the point of intersection of three functions. I have of course tried different things but haven't yet figured it out. Basically what I want is to plot three functions in one plane each to find the intersection point of these three functions. I need it because I am currently working with unconstrained optimization and linear programming regarding the Simplex method. I have found the point of maximum profit but at that point I also need to find the number of each of the three types of products that is produced. I am thinking it can be done by plotting these three functions in one plane each, but I haven't yet been able to figure it out.
Any help is appreciated.
Here is my script:
%%Opgave 3
%With M2x1,C2x1 and T2x1 I have been trying to solve each equation for x1.
M2x1=solve(40*x1+20*x2+10*x3==460,x1)
%M2x2=solve(40*x1+20*x2+10*x3==460,x2)
C2x1=solve(x1+4*x2*2*x3==48,x1)
%C2x2=solve(x1+4*x2*x3==48,x2)
T2x1=solve(2*x1+3.5*x2+5*x3==60,x1)
%T2x2=solve(2*x1+3.5*x2+5*x3==60,x2)
%[x1,x2,x3]=solve('x1=40*(23/2 - x3/4 - (23 - x3/2)/2)+20*(23 - x3/2)+10*x3','x1=(48 - 8*(6/x3)*x3)+4*(6/x3)*2*x3','x1=2*(30 - (5*x3)/2 - (7*(120/7 - (10*x3)/7))/4)+3.5*(120/7 - (10*x3)/7)+5*x3')
%[x1,x2,x3]=solve('x1=23/2 - x3/4 - x2/2','x1=48 - 8*x2*x3','30 - (5*x3)/2 - (7*x2)/4')
%[x1,x2]=solve('x1=23/2 - x3/4 - x2/2','x1=48 - 8*x2*x3')
figure(2);
%M2x1 = @(x2,x3) 23/2 - x3/4 - x2/2;
%C2x1 = @(x2,x3) 48 - 8*x2*x3;
%T2x1 = @(x2,x3) 30 - (5*x3)/2 - (7*x2)/4;
%n=ezsurf(M2x1,[-2 25 -2 25]);
hold on;
%v=ezsurf(C2x1,[-2 25 -2 25]);
%b=ezsurf(T2x1,[-2 25 -2 25]);
%legend('Mængde GaAs','CO2-udledning','Produktionstid')
%axis([-2 25 -2 25 -2 25]);
M2x2=23 - x3./2 - 2.*x1;
T2x3=12 - (7.*x2)/10 - (2.*x1)./5;
syms x2 x3
x2=-10:0.1:100;x3=-10:0.1:100;
M2x1=23/2 - x3./4 - x2./2;
C2x1=48 - 8.*x2.*x3;
T2x1=30 - (5.*x3)./2 - (7.*x2)./4;
plot3([M2x2,C2x1,T2x3])
%Finding maximum profit
T=[1 -120 -110 -100 0 0 0 0; 0 10 40 20 1 0 0 460; 0 2 1 4 0 1 0 48; 0 5 2 3.5 0 0 1 60]
[r,c]=size(T);
for i=2:(s-1)
if T(1,i)<0
cn=i %
Koef=T(2:r,c)./T(2:r,cn);
D=Koef>=0;
Koef=Koef(D);
Koefmin=min(Koef);
rn=find(Koef==Koefmin);
rn=rn(1)+1
for j=1:r
if j==rn
%does nothing with pivot row
else
mjk=(T(j,cn))./(T(rn,cn));
T(j,:)=T(j,:)-mjk*T(rn,:)
end
end
else
i=i+1;
end
end
z=T(1,c)
hold off
Where T of course is the augmented matrix and z is the optimal profit. x1 = type 1, x2 = type 2 and x3 = type 3.
Answers (0)
Categories
Find more on Calculus in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!