diff --git a/MATLAB/Area/Area between curves/Area bounded by curves of form x = f(y)/code.m b/MATLAB/Area/Area between curves/Area bounded by curves of form x = f(y)/code.m new file mode 100644 index 0000000..47b33f6 --- /dev/null +++ b/MATLAB/Area/Area between curves/Area bounded by curves of form x = f(y)/code.m @@ -0,0 +1,14 @@ +clear +clc +syms y +f = input("Enter right curve f(y): "); +g = input("Enter left curve f(y): "); +L = input("Enter limits of integration: [a,b]: "); +a = L(1);b = L(2); +Area = int(f-g,y,a,b); +disp(Area); +y1 = linspace(a,b,20);x1 = subs(f,y,y1); +y2 = y1;x2 = subs(g,y,y2); +plot(x1,y1);hold on;plot(x2,y2);hold off; +xlabel('x-axis');ylabel('y-axis'); +legend('f(x)','g(x)');grid on; \ No newline at end of file diff --git a/MATLAB/Area/Area between curves/Area bounded by curves of form y = f(x)/code.m b/MATLAB/Area/Area between curves/Area bounded by curves of form y = f(x)/code.m new file mode 100644 index 0000000..e441ccb --- /dev/null +++ b/MATLAB/Area/Area between curves/Area bounded by curves of form y = f(x)/code.m @@ -0,0 +1,14 @@ +clear all +clc +syms x +f = input("Enter the upper curve f(x): "); +g = input("Enter the lower curve g(x): "); +L = input("Enter the limits of integration for x [a,b]: "); +a = L(1);b = L(2); +x1 = linspace(a,b,20);y1 = subs(f,x,x1); +x2 = x1;y2 = subs(g,x,x2); +Area = int(f-g,x,a,b); +disp(['Area bounded by the curves f(x) and g(x) is ',char(Area)]) +plot(x1,y1);hold on;plot(x2,y2);hold off; +xlabel('x-axis');ylabel('y-label'); +legend('f(x)','g(x)');grid on; \ No newline at end of file diff --git a/MATLAB/Area/Area under the curve/Area under a curve between two values of x and x-axis/code.m b/MATLAB/Area/Area under the curve/Area under a curve between two values of x and x-axis/code.m new file mode 100644 index 0000000..af2713c --- /dev/null +++ b/MATLAB/Area/Area under the curve/Area under a curve between two values of x and x-axis/code.m @@ -0,0 +1,13 @@ +clear +clc +syms x +f = input('Enter curve f(x): '); +L = input('Enter limits [a,b]: '); +a = L(1);b=L(2); +Area = int(abs(f),x,a,b); +disp("The area is: ") +disp(Area) +x1 = linspace(a,b,20);y1 = subs(f,x,x1); +plot(x1,y1); +xlabel('x-axis');ylabel('y-label'); +legend('f(x)');grid on; \ No newline at end of file diff --git "a/MATLAB/Area/The area bounded by the curves \360\235\221\246 = 2 \342\210\222 \360\235\221\245 and the line \360\235\221\246 = \342\210\222x from \360\235\221\245 = \342\210\2221 to 2/code.m" "b/MATLAB/Area/The area bounded by the curves \360\235\221\246 = 2 \342\210\222 \360\235\221\245 and the line \360\235\221\246 = \342\210\222x from \360\235\221\245 = \342\210\2221 to 2/code.m" deleted file mode 100644 index 746d698..0000000 --- "a/MATLAB/Area/The area bounded by the curves \360\235\221\246 = 2 \342\210\222 \360\235\221\245 and the line \360\235\221\246 = \342\210\222x from \360\235\221\245 = \342\210\2221 to 2/code.m" +++ /dev/null @@ -1,14 +0,0 @@ -clear all -clc -syms x -f=input('Enter the upper curve f(x): '); -g=input('Enter the lower curve g(x): '); -L=input('Enter the limits of integration for x [a,b]:'); -a=L(1); b=L(2); -Area=int(f-g,x,a,b); -disp(['Area bounded by the curves f(x) and g(x) is: ',char(Area)]); -x1=linspace(a,b,20);y1=subs(f,x,x1); -x2=x1;y2=subs(g,x,x1); -plot(x1,y1);hold on; plot(x2,y2);hold off; -xlabel('x-axis');ylabel('y-axis'); -legend('f(x)','g(x)');grid on; \ No newline at end of file diff --git a/MATLAB/Volume/Solids of Revolution/Revolving a curve y = x^(1/2) about line y=1 from x=1 to x=4/code.m b/MATLAB/Volume/Solids of Revolution/Revolving a curve y = x^(1/2) about line y=1 from x=1 to x=4/code.m new file mode 100644 index 0000000..941b7ad --- /dev/null +++ b/MATLAB/Volume/Solids of Revolution/Revolving a curve y = x^(1/2) about line y=1 from x=1 to x=4/code.m @@ -0,0 +1,21 @@ +% Evaluation of Volume of solid of revolution +clear +clc +syms x +f(x)=sqrt(x); % Given function +yr=1; % Axis of revolution y=yr +I=[0,4]; % Interval of integration +a=I(1);b=I(2); +vol=pi*int((f(x)-yr)^2,a,b); +disp('Volume of solid of revolution is: '); +disp(vol); % Visualization if solid of revolution +fx=matlabFunction(f); +xv = linspace(a,b,101); % Creates 101 points from a to b +[X,Y,Z] = cylinder(fx(xv)-yr); +Z = a+Z.*(b-a); % Extending the default unit height of the +% cylinder profile to the interval of integration +surf(Z,Y+yr,X) % Plotting the solid of revolution about y=yr +hold on; +plot([a b],[yr yr],'-r','LineWidth',2); % Plotting the line y=yr +view(22,11); % 3-D graph viewpoint specification +xlabel('X-axis');ylabel('Y-axis');zlabel('Z-axis'); \ No newline at end of file