So I am trying to figure out a code which does the following:
Gets 2 functions from the user
finds out the area of intersection no matter how many finite intersections
you do not have to specify what is the upper and lower curve
fills in the area with a specific colour
Code: What it doesnt do is figure out how to find out upper and lower curve on its own plus doesnt do it for multiple intersections
clc
clear
syms x
y1=input('enter the upper curve as a function of x : ')
y2=input('enter the lower curve as a function of x : ')
t=solve(y1-y2);
t=double(t);
a=int(y1-y2,t(1),t(2))
d=[t(1)-0.2 t(2)+0.2]
ez1=ezplot(y1,d);
set(ez1,'color','r')
hold on
ez2=ezplot(y2,d);
legend('y1','y2')
xv=linspace(t(1),t(2));
y1v=subs(y1,x,xv)
y2v=subs(y2,x,xv)
x=[xv,xv];
y=[y1v,y2v];
fill(x,y,'g')
grid on
0 Comments
Sign in to comment.