Question

In: Advanced Math

1. Magnitude & Direction of Vector Write a function m-file to find the magnitude and the...

1. Magnitude & Direction of Vector

Write a function m-file to find the magnitude and the direction of cosine of vector F which expresses 3 dimension - x, y, and z.

Here are requirements for the function m-file.

- Parameter-list (input(s)): · 3 dimensional vector · row vector or column vector

- undetermined - Return Value (outputs):

· Magnitude of a given vector, |F| = √ F2 x + F2 y + F2 z

· Angles(degree) from direction of cosine cos(α) = Fx |F| cos(β) = Fy |F| cos(γ) = Fz |F|

· Order of outputs : [Magnitude, α, β, γ]

- Function name : ‘Mag_Vec_yourEmailAccount’ Using a script m-file which will call the Mag_Vec_yourEmailAccount function, save outputs with following given inputs. - F1 = 3ˆi + 2ˆj − 6ˆk. Save it on EX1_1.dat.

- F2 = 4ˆi − 2ˆk. Save it on EX1_2.dat.

- F3 = 4ˆi + 3ˆj. Save it on EX1_3.dat.

- F4 = 5ˆj − 12ˆk. Save it on EX1_4.dat.

- F5 =ˆi +ˆj + ˆk. Save it on EX1_5.dat.

using mathlab functions, thank you!

Solutions

Expert Solution

function [Magnitude, alp, bit, gamma] = Mag_Vec(F)
Magnitude=sqrt(F(1)^2+F(2)^2+F(3)^2);
  
alp = acos(F(1)/Magnitude); % acos = invers cos(th)
bit = acos(F(2)/Magnitude); % alp, bit ,gamma calculating as radian
gamma = acos(F(3)/Magnitude);
  
alp = 180*alp/pi; % alp, bit ,gamma calculating as degree
bit = 180*bit/pi;
gamma = 180*gamma/pi;
end

clc
clear

fid = fopen('EX1_1.dat','w');
F1=[3, 2, -6]; % F1 = 3i+2j-6k;
[Magnitude, alp, bit, gamma] = Mag_Vec(F1);
Sol = [Magnitude, alp, bit, gamma];
fprintf(fid,'%f \n',Sol);
fclose(fid);

fid = fopen('EX1_2.dat','w');
F2=[4, 0, -2]; % F1 = 4i-2k;
[Magnitude, alp, bit, gamma] = Mag_Vec(F2);
Sol = [Magnitude, alp, bit, gamma];
fprintf(fid,'%f \n',Sol);
fclose(fid);

fid = fopen('EX1_3.dat','w');
F3=[4, 3, 0]; % F1 = 4i+3j;
[Magnitude, alp, bit, gamma] = Mag_Vec(F3);
Sol = [Magnitude, alp, bit, gamma];
fprintf(fid,'%f \n',Sol);
fclose(fid);

fid = fopen('EX1_4.dat','w');
F4=[0, 5, -12]; % F1 = 4j+12k;
[Magnitude, alp, bit, gamma] = Mag_Vec(F4);
Sol = [Magnitude, alp, bit, gamma];
fprintf(fid,'%f \n',Sol);
fclose(fid);

fid = fopen('EX1_5.dat','w');
F5=[1, 1, 1]; % F1 = i+j+k;
[Magnitude, alp, bit, gamma] = Mag_Vec(F5);
Sol = [Magnitude, alp, bit, gamma];
fprintf(fid,'%f \n',Sol);
fclose(fid);

%to see the EX1_1.dat file enter in command window- type EX1_1.dat


Related Solutions

The vector A has a magnitude of 16.5 and a direction of 146 degrees. The vector...
The vector A has a magnitude of 16.5 and a direction of 146 degrees. The vector B has a magnitude of 17 and a direction of 69.5 degrees. The vector C has a magnitude of 16.5 and a direction of 32 degrees. All angles are measured counterclockwise from the positive x axis. The vector D follows the following relation: D = A + B − C What are the magnitude and direction of the vector D?
1. Writing new functions for the following: Find the magnitude of a vector (as one function...
1. Writing new functions for the following: Find the magnitude of a vector (as one function that works on both 2D and 3D vectors). Normalize a vector (also working for both 2D and 3D). Compute the dot product of two vectors. Compute the cross product of two vectors. Get the distance between two positions. Get the angle between two vectors. Get a point on a ray (given the origin, direction, and parametric value along ray). 2. Use Python lists to...
Find the direction and magnitude of the following vectors. Part A A⃗ =( 28 m )x^+(...
Find the direction and magnitude of the following vectors. Part A A⃗ =( 28 m )x^+( -13 m )y^ Express your answer in degrees using three significant figures. θA=   ∘ counterclockwise from the positive xaxis Part B Express your answer in meters using two significant figures. |A⃗ | =   m   Part C B⃗ =( 4.5 m )x^+( 20 m )y^ Express your answer in meters using two significant figures. θB=   ∘ counterclockwise from the positive xaxis Part D Express your...
A vector, V, has a magnitude of 350 N and a direction of 55°.   Determine the...
A vector, V, has a magnitude of 350 N and a direction of 55°.   Determine the following: Vx = ______ Vy = ______ If Vx = 12 m and Vy = 17 m then determine the following: What is the magnitude, V, of this vector? What is the direction, θ, of this vector? A hiker walks 2.5 km at an angle of 45 degrees north of west, and then hikes 4.0 km at an angle of 30 degrees north of...
vector a has a magnitude of 16m and a direction of 65 above the negative x...
vector a has a magnitude of 16m and a direction of 65 above the negative x axis. vecot b has a madnitude of 9.0m and is directed along the negative x axis. find the magnitude and direction of A+B
Find the magnitude of the vector sum r of the vector displacements c and d whose...
Find the magnitude of the vector sum r of the vector displacements c and d whose components in meters along three perpendicular directions are cx= 7.8, cy= -3.8, cz= -6.4; dx= 4.7, dy= -2.1, dz= 3.7;
Write a .m function file on MATLAB that reads the parameters stored in the file missile...
Write a .m function file on MATLAB that reads the parameters stored in the file missile data.txt into MATLAB. The function should have the following declaration: function [X0, Y0, Z0, m0, mf, Thmag0, theta, phi, Tburn] = read input( input filename, M id) where input filename is a string variable denoting the name of the file to be read and M_id is an integer which denotes the missile ID. The outputs are the initial position (X0, Y0, Z0), initial and...
Magnitude and direction.
A long straight wire in the horizontal plane carries a current of 50A in north to south direction. Find the magnitude and direction of B at a point 2.5m east of the wire.
Let vector B = 5.50 m at 60°. Let vector C have the same magnitude as...
Let vector B = 5.50 m at 60°. Let vector C have the same magnitude as vector A and a direction angle greater than that of vector A by 25°. Let vector A · vector B = 27.0 m2 and vector B · vector C = 34.5 m2. Find the magnitude and direction of vector A.
1.Find the derivative of the product between a scalar function and a vector function using the...
1.Find the derivative of the product between a scalar function and a vector function using the product formula. 2. Find the volume of an irregular solid using triple integration, the first integral should have at least one limit with variables. 3. Determine the moment of inertia of an irregular solid using triple integration. the first integral should have at least one limit with variables. 4. Find the angle between two lines using dot product. the two lines should not pass...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT