0% found this document useful (0 votes)
28 views14 pages

Arinze - Project 2

math

Uploaded by

Sami rajpoot
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views14 pages

Arinze - Project 2

math

Uploaded by

Sami rajpoot
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 14

MATH-240-402 2022FA Calculus III

MATLAB PROJECT PART 2

Student Name: Arinze Ezeifeka


Student ID: 0621268
Howard Community College

MATLAB PROJECT 2
Contents
PART a: Plot the points in red A (7, -5), B (6, 0) and C (-3,5):.....................................................................2
Part b: Plot the segment AB in blue...........................................................................................................3
Part c: A line parallel to segment AB and through (1,2).............................................................................4
Part d: Distance between point C and line AB...........................................................................................5
Part e: Graph the line in 3D through points P (4,0,-3) and Q (-7,2,1).........................................................6
Part f: Graph the figure f (x,y,z)=(cos(2t),sin(2t),t).....................................................................................7
Part g: Graph the equation z=3-3x+3y (column 1).....................................................................................8
Part h: Graph the equation z=x 2−3 y 2 (column 1)...............................................................................9
Part j: Graph the equation z=x 2+ 3 y 2+9 z 2=27 (column 1).............................................................10
Part k: Graph the equation z=3 x 2+ 8 y 2 (column 1)............................................................................11
Part l: Graph the equation −4 x 2+25 y 2+ z 2=100 (column 1)...........................................................12

MATLAB PROJECT 2
Figure 1: Part a............................................................................................................................................4
Figure 2: Part b............................................................................................................................................5
Figure 3: Part c.............................................................................................................................................6
Figure 4: part d............................................................................................................................................7
Figure 5: part e............................................................................................................................................8
Figure 6: part f.............................................................................................................................................9
Figure 7: part g..........................................................................................................................................10
Figure 8: Part h..........................................................................................................................................11
Figure 9: part j...........................................................................................................................................12
Figure 10: part k........................................................................................................................................13
Figure 11: part l.........................................................................................................................................14

MATLAB PROJECT 2
PART a: Plot the points in red A (7, -5), B (6, 0) and C (-3,5):
Code:
%MATLAB PROJECT 2
%%PART a
figure % initializing the figure
scatter(7,-5,'r') % plotting point A in red
hold on % to plot next point on same plot
scatter(6,0,'r') % plotting point B in red
hold on % to plot next point on same plot
scatter(-3,5,'r') % plotting point C in red
xlim([-10 10]) % defining x-axis limits
ylim([-10 10]) % defining y-axis limits
grid on % to on grid
title(" PART A: plot the points in red A(7,-5), B(6,0) and C(-3,5)")
xlabel("x values")
ylabel("y values")

Result:

Figure 1: Part a

MATLAB PROJECT 2
Part b: Plot the segment AB in blue
Code:
%% PART b
figure % initializing the figure
syms x y % Variables for eqaution
x_b=[7 6]; % Array of x points of segment AB
y_b=[-5 0]; % Array of y points of segment AB
slope_c=(y_b(2)-y_b(1))/(x_b(2)-x_b(1)); % Slope
disp(" Equation of segment AB is: ")
y_AB=slope_c*(x-x_b(1))+y_b(1) % Equation of segment AB
plot(x_b,y_b,'b') %Plotting the segment AB
xlim([5 8]) % defining x-axis limits
ylim([-6 1]) % defining y-axis limits
grid on
title(" PART B: Plot the segment AB in blue")
xlabel("x values")
ylabel("y values")
legend("Segment AB")

Result:

Figure 2: Part b

MATLAB PROJECT 2
Part c: A line parallel to segment AB and through (1,2)
Code:
%% PART c
figure
syms x_c y_c x % initializing the figure
x_c=[7 6]; % Array of x points of segment AB
y_c=[-5 0]; % Array of y points of segment AB
x_point=1; % x point through para;lel line is passing
y_point=2; % x point through parallel line is passing
slope_c=(y_c(2)-y_c(1))/(x_c(2)-x_c(1)); %Slope
disp("Parallel line is: ")
y_parallel=slope_c*(x-x_point)+y_point % Parralel line is
x=x_c;
y_parallel_points=slope_c*(x-x_point)+y_point;
plot(x_c,y_c,x_c,y_parallel_points)
xlim([5 8]) % defining x-axis limits
ylim([-30 2])
grid on
title(" PART c: A line parallel to segment AB and through (1,2)")
xlabel("x values")
ylabel("y values")
legend("Segment AB","Parallel line")

Result:

Figure 3: Part c

MATLAB PROJECT 2
Part d: Distance between point C and line AB
Code:
%% PART d
%Distance between a point and line is given as
% Ax0 + By0 + C
% D = --------------
% sqrt(x^2 +y^2)

C_x=-3;
C_y=5;
coefficients=coeffs(y_AB); %% y_AB comes from part b so run part b first to
store value in workspace
Nominator=abs(coefficients(2)*C_x +(-1)*C_y + coefficients(1)); %finding
nominator of formula
Denominator=(sqrt(coefficients(2)^2+(-1)^2)); %finding denominator of formula
disp("distance between line AB and point C is")
Distance=(Nominator/Denominator) %distance

Results:

Figure 4: part d

Part e: Graph the line in 3D through points P (4,0,-3) and Q (-7,2,1)


Code:
%% PART e
figure
%points are P(4,0,-3) and Q(-7,2,1)
x_e=[4,-7]; % vector of x values of points P and Q
y_e=[0,2]; % vector of x values of points P and Q
z_e=[-3,1]; % vector of x values of points P and Q
plot3(x_e,y_e,z_e) %3D plot
title(" PART e: A 3D line passing through points P and Q)")
xlabel("x values")
ylabel("y values")
zlabel("z values")
legend("3D line")
grid on

MATLAB PROJECT 2
Result:

Figure 5: part e

Part f: Graph the figure f (x,y,z)=(cos(2t),sin(2t),t)


Code:
%% PART f
figure
t=-10:0.01:10;
x_f=cos(2*t);
y_f=sin(2*t);
z_f=t;
plot3(x_f,y_f,z_f)
title(" PART f: Plotting Function f(x,y,z)=(cos(t),sin(t),t))")
xlabel("x values")
ylabel("y values")
zlabel("z values")
legend("f(x,y,z)=(cos(t),sin(t),t))")

MATLAB PROJECT 2
Result:

Figure 6: part f

Part g: Graph the equation z=3-3x+3y (column 1)

Code:
%% PART g
syms x y
figure
z_1=3-2*x+3*y; %defining function
ezsurf(z_1,[-3,3,-3,3]) % Plotting
xlabel("x values [-3,3]") %x label
ylabel("y values [-3,3]") %y label
zlabel("z values") %z label
title("z = 3- 2x +3y ")

MATLAB PROJECT 2
Result:

Figure 7: part g

Part h: Graph the equation z=x 2−3 y 2 (column 1)

Code:
%% PART h
figure
syms x y
z_2=x^2-3*y^2; %defining function
ezsurf(z_2,[-5,5,-5,5]) %plotting
xlabel("x values [-5,5]")%x label
ylabel("y values [-5,5]") %y label
zlabel("z values") %z label
title("z =x^2 - 3y^2")

MATLAB PROJECT 2
Result:

Figure 8: Part h

Part j: Graph the equation z=x 2 +3 y 2+ 9 z 2=27 (column 1)

Code:
%% PART j
figure
syms x y z
z_3=x.^2+3*y.^2+9*z.^2-27; %defining equation
fimplicit3(z_3,[-5,5]) %Plotting using fimplicit3 command
xlabel("x values [-5,5]") %x label
ylabel("y values [-5,5]") %y label
zlabel("z values") %z label
title("x^2 + 3y^2 + 9z^2 =27")

Results:

MATLAB PROJECT 2
Figure 9: part j

Part k: Graph the equation z=3 x 2+ 8 y 2 (column 1)

Code:
figure
syms x y
z_4=3*x^2+8*y^2; %function
ezsurf(z_4,[-5,5,-5,5]) %Plotting
xlabel("x values [-5,5]") %x label
ylabel("y values [-5,5]")%y label
zlabel("z values")%z label
title("z =3x^2 + 8y^2")

Result:

MATLAB PROJECT 2
Figure 10: part k

Part l: Graph the equation −4 x 2+25 y 2 + z 2=100 (column 1)

Code:
%% PART l
figure
syms x y z
z_5=-4*x.^2+25*y.^2+z.^2-100; %defining equation
fimplicit3(z_5,[-20,20]) %Plotting using fimplicit3 command
xlabel("x values [-20,20]") %x label
ylabel("y values ") %y label
zlabel("z values") %z label
title("-4x^2 + 25y^2 + z^2 =100")

Result:

MATLAB PROJECT 2
Figure 11: part l

MATLAB PROJECT 2

You might also like