In: Mechanical Engineering
Use MATLAB to determine the intersection point for the sets of equations shown below. Use the backslash when possible.Graph the equations with different colors, and plot the intersection point with a red star marker. If the equations do not intersect, graph them anyway.
Include a legend:
a) -4x1 + 2x2 = 10 b)-4x1+2x2^3 = 10
x1 + x2 = -8 x1+ x2 = -8
Program a)
clear all;
clc;
syms x1 x2
f1(x1,x2)=-4*x1+2*x2-10;
f2(x1,x2)=x1+x2+8;
ez1=ezplot(f1);
set(ez1,'color','blue')
hold on;
ez2=ezplot(f2);
set(ez2,'color','black');
hold on;
%following procedure is to find x2 such that f1=f2 (i.e.
intersection
%point) and then finding x1 from x2.
b=solve(((2*x2-10)/4)+8+x2==0); % x2 for f1=f2
a=-b-8; %x1 from x2
plot(a,b,'*','color','red')
legend('-4x1 + 2x2 = 10','x1 + x2 = -8','intersection point')
title('Case(a)');
Graph
Program b)
clear all;
clc;
syms x1 x2
f1(x1,x2)=-4*x1+2*(x2^3)-10;
f2(x1,x2)=x1+x2+8;
ez1=ezplot(f1,[-8,8]);
set(ez1,'color','blue')
hold on;
ez2=ezplot(f2,[-8,8]);
set(ez2,'color','green')
%following procedure is to find x2 such that f1=f2 (i.e.
intersection
%point) and then finding x1 from x2.
b=solve(((2*(x2^3)-10)/4)+8+x2==0); % x2 for f1=f2
a=-b-8; %x1 from x2
plot(a,b,'*','color','red')
legend('-4x1 + 2(x2^3) = 10','x1 + x2 = -8','intersection
point')
title('Case(b)');
Graph