Question

In: Advanced Math

A Cartesian vector can be thought of as representing magnitudes along the x-, y-, and z-axes...

A Cartesian vector can be thought of as representing magnitudes along the x-, y-, and z-axes multiplied by a unit vector (i, j, k). For such cases, the dot product of two of these fectors {a} and {b} corresponds to the product of their magnitudes and the cosine of the angle between their tails as in {a}⋅ {b} = abcos(theta)

The cross product yields another vector, {c} = {a} × {b} , which is perpendicular to the plane defined by {a} and {b} such that its direction is specified by the right-hand rule. Develop and M-file function that is passed two such vectors and returns Theta, {c} and the magnitude of {c}, and generates a three-dimensional plot of the three vectors {a}, {b}, and {c} with their origins at zero. Use dashed lines for {a} and {b} and a solid line for {c}. Test your function using the following cases:

A. a = [ 6 4 2 ]; b = [ 2 6 4 ];

B. a = [ 3 2 -6 ]; b = [ 4 -3 1];

C. a = [ 2 -2 1 ]; b = [ 4 2 -4 ];

D. a = [ -1 0 0 ]; b = [ 0 -1 0 ];

I know how to find theta, {c}, and the magnitude of {c}, I just don't know how to plot a 3-dimensional graph so if someone could help me with that part of the code for MATLAB

Solutions

Expert Solution

MATLAB Script:

close all
clear
clc

fprintf('Part A\n-------------------------------------------\n')
a = [6 4 2]; b = [2 6 4];
[Theta, Magnitude] = cross_prod(a, b);
fprintf('Theta (in radians): %.4f\n', Theta)
fprintf('Magnitude: %.4f\n', Magnitude)

fprintf('\nPart B\n-------------------------------------------\n')
a = [3 2 -6]; b = [4 -3 1];
[Theta, Magnitude] = cross_prod(a, b);
fprintf('Theta (in radians): %.4f\n', Theta)
fprintf('Magnitude: %.4f\n', Magnitude)

fprintf('\nPart C\n-------------------------------------------\n')
a = [2 -2 1]; b = [4 2 -4];
[Theta, Magnitude] = cross_prod(a, b);
fprintf('Theta (in radians): %.4f\n', Theta)
fprintf('Magnitude: %.4f\n', Magnitude)

fprintf('\nPart D\n-------------------------------------------\n')
a = [-1 0 0]; b = [0 -1 0];
[Theta, Magnitude] = cross_prod(a, b);
fprintf('Theta (in radians): %.4f\n', Theta)
fprintf('Magnitude: %.4f\n', Magnitude)

function [Theta, Magnitude] = cross_prod(a, b)
c = cross(a, b);
Theta = acos(dot(a, b)/sqrt(dot(a, a)*dot(b, b)));
Magnitude = sqrt(dot(c, c));
  
% Plotting
origin = [0 0 0];
figure
x = [origin(1) a(1)]; y = [origin(2) a(2)]; z = [origin(3) a(3)];
plot3(x, y, z, '--'), hold on % Plot vector a
  
x = [origin(1) b(1)]; y = [origin(2) b(2)]; z = [origin(3) b(3)];
plot3(x, y, z, '--') % Plot vector b
  
x = [origin(1) c(1)]; y = [origin(2) c(2)]; z = [origin(3) c(3)];
plot3(x, y, z), hold off % Plot vector c
  
grid on
xlabel('x'), ylabel('y'), zlabel('z')
title('Cross Product - 3D Plot')
legend('a', 'b', 'c')
end

Output:

Part A
-------------------------------------------
Theta (in radians): 0.6669
Magnitude: 34.6410

Part B
-------------------------------------------
Theta (in radians): 1.5708
Magnitude: 35.6931

Part C
-------------------------------------------
Theta (in radians): 1.5708
Magnitude: 18.0000

Part D
-------------------------------------------
Theta (in radians): 1.5708
Magnitude: 1.0000

Plots:


Related Solutions

Compute the line integral of the vector field F(x, y, z) = ⟨−y, x, z⟩ along...
Compute the line integral of the vector field F(x, y, z) = ⟨−y, x, z⟩ along the curve which is given by the intersection of the cylinder x 2 + y 2 = 4 and the plane x + y + z = 2 starting from the point (2, 0, 0) and ending at the point (0, 2, 0) with the counterclockwise orientation.
The 500-N force F is applied to the vertical pole as shown 1. Determine the scalar components of the force vector F along the x'- and y'-axes. 2. Determine the scalar components of F along the x- and y'-axes
The 500-N force F is applied to the vertical pole as shown1. Determine the scalar components of the force vector F along the x'- and y'-axes. 2. Determine the scalar components of F along the x- and y'-axes.
in a cartesian coordinate space, a curved path is defined as y=sin(x).Find the vector that is...
in a cartesian coordinate space, a curved path is defined as y=sin(x).Find the vector that is normal to the path everywhere.(xy:no unit)
Verify the Divergence Theorem for the vector field F(x, y, z) = < y, x ,...
Verify the Divergence Theorem for the vector field F(x, y, z) = < y, x , z^2 > on the region E bounded by the planes y + z = 2, z = 0 and the cylinder x^2 + y^2 = 1. By Surface Integral: By Triple Integral:
The vector field given by E (x,y,z) = (yz – 2x) x + xz y +...
The vector field given by E (x,y,z) = (yz – 2x) x + xz y + xy z may represent an electrostatic field? Why? If so, finding the potential F a from which E may be obtained.
Compute the derivative of the given vector field F. Evaluate the line integral of F(x,y,z) = (y+z+yz , x+z+xz , x+y+xy )
Compute the derivative of the given vector field F. Evaluate the line integral of F(x,y,z) = (y+z+yz , x+z+xz , x+y+xy )over the path C consisting of line segments joining (1,1,1) to (1,1,2), (1, 1, 2) to (1, 3, 2), and (1, 3, 2) to (4, 3, 2) in 3 different ways, along the given path, along the line from (1,1,1) to (4,3,2), and finally by finding an anti-derivative, f, for F.
Consider the scalar functions f(x,y,z)g(x,y,z)=x^2+y^2+z^2, g(x,y,z)=xy+xz+yz, and=h(x,y,z)=√xyz Which of the three vector fields ∇f∇f, ∇g∇g and...
Consider the scalar functions f(x,y,z)g(x,y,z)=x^2+y^2+z^2, g(x,y,z)=xy+xz+yz, and=h(x,y,z)=√xyz Which of the three vector fields ∇f∇f, ∇g∇g and ∇h∇h are conservative?
Verify the Divergence Theorem for the vector eld F(x; y; z) = hy; x; z2i on...
Verify the Divergence Theorem for the vector eld F(x; y; z) = hy; x; z2i on the region E bounded by the planes y + z = 2, z = 0 and the cylinder x2 + y2 = 1. Surface Integral: Triple Integral:
a. What is N-S equations for incompressible flows in cartesian coordinates in long form (in x,y,z...
a. What is N-S equations for incompressible flows in cartesian coordinates in long form (in x,y,z coordinates)? b. What is continuity equation and N-S equations for incompressible flows in polar coordinates in long form (in r,θ,z) c. What is N-S equations in x direction for Planar Couette- Pouseille flow and derive an equation for velocity variation using boundary layer conditions d. Assume an incompressible, steady, axissymmetric, fully developed Pouseille flow in a cylindrical pipe (infinitesimally long in z direction). The...
1) Within a cubic unit cell on which you have labeled the x, y and z-axes:...
1) Within a cubic unit cell on which you have labeled the x, y and z-axes: a) Sketch the (110) plane. b) Sketch a direction from the <100> family that is also on the (110) plane. Label its direction indices. c) Sketch a direction from the <110> family that is also on the (110) plane. Label its direction indices. d) Sketch a direction from the <111> family that is also on the (110) plane. Label its direction indices. 2) Make...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT