Describe what each code snippet does and how it might be used in Statics. Describe in general terms what Statics calculation is being performed by each code snippet. What is input to the calculation and what results are given? Give definitions not numbers. Hint: all arrays are components of vectors [ x, y, z ].
Code 1
V1 = [ 0, 1, 2 ]; V2 = [ 3, -4, 5 ]; x = 1; y = 2; z = 3; vXv = [ V1(y)*V2(z) - V1(z)*V2(y), V1(z)*V2(x) - V1(x)*V2(z) ... , V1(x)*V2(y) - V1(y)*V2(x)];
Note: ... must be at the end of the line as it is the Matlab way to continue a statement on the next line.
Code 2
V1 = [ 0, 1, 2 ]; V2 = [ 3, -4, 5 ]; x = 1; y = 2; z = 3; vDv = V1(x)*V2(x) + V1(y)*V2(y) + V1(z)*V2(z)
Code 3:
V = [ 6, -2, 3 ]; Mag = sqrt( sum(V .^2 )); lambda = V ./ Mag
Code 4
v = [ 1, 2, 3 ]; r1 = [ 0.3, -0.4, 0.5 ]; r2 = r1 + v; r1Xf = cross(r1,v); r2Xf = cross(r2,v); isequal(r1Xf,r2Xf)
What should be the result of this snippet?
Next, write a section of code as described below:
Write a code to compute all 6 permutations of the mixed triple product of the three vectors:
P→=0i→+3j→+0k→
Q→=0i→+0j→+5k→
S→=2i→+0j→+0k→
Then change the first vector to, P→=2i→+3j→+5k→ and compare the results. To make this easier type the commands "help dot" and "help cross" into Matlab.
A code to compute all 6 permutations of the mixed triple product of the three vectors is given as follows:
Code 1:
V1 = [0,1,2];
Declares a vector 0i + 1j + 2k
V2 = [3,-4,5];
Declares a vector 3i - 4j + 5k
x = 1;
Stores a value of 1 in x
y = 2;
?Stores a value of 2 in y
z = 3;
?Stores a value of 3 in z
vXv = [V1(y)*V2(z) - V1(z)*V2(y), V1(z)*V2(x) - V1(x)*V2(z),
V1(x)*V2(y) - V1(y)*V2(x)] ;
Calculates the cross product if the two vectors V1 and
V2
vXv = [13 6 -3] is the MATLAB output.
Code 2:
V1 = [0,1,2];
Declares a vector 0i + 1j + 2k
V2 = [3,-4,5];
Declares a vector 3i - 4j + 5k
x = 1;
Stores a value of 1 in x
y = 2;
?Stores a value of 2 in y
z = 3;
?Stores a value of 3 in z
vDv = V1(x)*V2(x) + V1(y)*V2(y) + V1(z)*V2(z);
Calculates the dot product if the two vectors V1 and
V2
vDv = 6 is the MATLAB output.
Code 3:
V = [6,-2,3];
Declares a vector 6i - 2j + 3k
Mag = sqrt (sum(V.^2));
V.^2 does the aquare of each element and hence V.^2 =
[36,4,9]
sum(V.^2) does the sum of all elements of V.^2 and hence sum =
36+4+9 = 49
sqrt (sum(V.^2)) gives the square root of sum(V.^2) and hence sqrt
(sum(V.^2)) = 7
So, M = 7
lamda = V ./ Mag;
V ./ Mag divides each element of V by Mag
So, lamda = is the MATLAB output
Code 4:
v = [1,2,3];
Declares a vector 1i + 2j + 3k
r1 = [0.3, -0.4, 0.5];
Declares a vector 0.3i - 0.4j +
0.5k
r2 = r1 + v;
Element-wise addition of the vectors r1 and v occurs
and the result get stores in r2
r2 = [1.3 1.6 3.5]
r1Xf = cross(r1,v);
r1Xf stores the value of the cross product of r1 and v,
r1 X v.
r1Xf = [-2.2 -0.4 1]
r2Xf = cross(r2,v);
r2Xf stores the value of the cross product of r2 and v,
r2 X v.
r2Xf = [-2.2 -0.4 1]
isequal(r1Xf ,r2Xf)
The MATLAB output is 0 since r1Xf and r2Xf are both
equal.
The MATLAB code is as follows:
%Declaring Vector P
P = [0, 3, 0];
%Declaring Vector Q
Q = [0, 0, 5];
%Declaring Vector S
S = [2, 0, 0];
%Finding the first mixed triple product P.(Q X
S)
A1 = dot(P,cross(Q,S))
%A1 = 30
%Finding the second mixed triple product P.(S X
Q)
B1 = dot(P,cross(S,Q))
%B1 = -30
%Finding the third mixed triple product Q.(P X
S)
C1 = dot(Q,cross(P,S))
%C1 = 30
%Finding the fouth mixed triple product Q.(S X
P)
D1 = dot(Q,cross(S,P))
%D1 = 30
%Finding the fifth mixed triple product S.(P X
Q)
E1 = dot(S,cross(P,Q))
%E1 = 30
%Finding the sixth mixed triple product S.(Q X
P)
F1 = dot(S,cross(Q,P))
%F1 = 30
%Redcalaring the vector P to the new value
P = [2, 3, 5];
%Finding the first mixed triple product P.(Q X
S)
A2 = dot(P,cross(Q,S))
%A2 = 30
%Finding the second mixed triple product P.(S X
Q)
B2 = dot(P,cross(S,Q))
%B2 = -30
%Finding the third mixed triple product Q.(P X
S)
C2 = dot(Q,cross(P,S))
%C2 = -30
%Finding the fouth mixed triple product Q.(S X
P)
D2 = dot(Q,cross(S,P))
%D2 = 30
%Finding the fifth mixed triple product S.(P X
Q)
E2 = dot(S,cross(P,Q))
%E2 = 30
%Finding the sixth mixed triple product S.(Q X
P)
F2 = dot(S,cross(Q,P))
%F2 = -30
% The corresponding values of the mixed triple product remain
unchanged since the new P = old P + Q + S., i.e. A1 = A2, B1 = B2,
C1 = C2, D1 = D2, E1 = E2, F1 = F2
Describe what each code snippet does and how it might be used in Statics. Describe in...
Module 3 Reading and Writing Code One of the things to learn in this course is OD. how to use Matlab or other computational tools for helping to solve Statics and other Engineering problems. The best way to learn how to code is by reading code. Belovw are several un-commented code snippets for computing things you will encounter in Statics. For this discussion first, describe what each code snippet does and how it might be used in Statics. Describe in...
MatLab Engineering Describe what each code snippet does and how it might be used in Statics. Describe in general terms what Statics calculation is being performed by each code snippet. What is input to the calculation and what results are given? Give definitions not numbers. All of these involve some concept covered in this module. Code 1 Magnitude = 5; Angle = 210; X = Magnitude * cosd( Angle ) Y = Magnitude * sind( Angle ) Code 2 Xcomponents...
A key point is that in Matlab the equals sign, "=", is an assignment. It takes the result of what is on the right side and puts it in the place named on the left side. Matlab is a script language so it works one line at a time from top to bottom. For this discussion describe what each code snippet does and how it might be used in Statics. Describe in general terms what Statics calculation is being performed...
2. a)Write the ARM ALP conditional code snippet for the following statements written in C-language. Assume R1 to Rn as06 variables Let R1, R2, R3 contain the starting addresses of arrays X, Y and Z respectively Use Register R4 for variable i. Display appropriate messages. While (i+10) else Z[i] XiYi; b)i Write a program to display a message "This is an examination Question" on the screen using 06 a function sub program Note the following Address of the string to...
Using java fix the code I implemented so that it passes the JUnit Tests. MATRIX3 public class Matrix3 { private double[][] matrix; /** * Creates a 3x3 matrix from an 2D array * @param v array containing 3 components of the desired vector */ public Matrix3(double[][] array) { this.matrix = array; } /** * Clones an existing matrix * @param old an existing Matrix3 object */ public Matrix3(Matrix3 old) { matrix = new double[old.matrix.length][]; for(int i = 0; i <...
using matlab to solve this problem as soon as possible
thanks
use
matlab to slove the problem as soon as possible
solve the activity of number 1&2&3 by using matlab
for
this problem i need from you to solve activity one and two and
three by using matlab
DIRECTIONS: Perform the following using MATLAB. After the simulation, your report must be uploaded in the Moodle Learning system. ACTIVITY I. VECTORS AND ITS OPERATIONS Procedure 1: Define two vectors a and...
For each graph below, you are instructed to find the RMS.
However, do NOT find it. Instead, find the equation for
each "segment" of the graph.
For example:
Do only the green part.
Remember to not skip any steps and explain/show HOW you
got the equations.
Period (T= 6 ms) Vminimum = 0V,Vpeak = 6V тії Voltage waveform falls across R2=102. Vrms=?, Power dissipation in R2? Write equations for each segment V1 R2 {R2} v7(t) = 2t v2(t) = -2t...
[16 marks] Provide concise answers and brief justification and reasoning (a) Determine the period of the function f(t) = n+|cos(t)(3+)sin(3tt) (b) Consider the 4-periodic function g(t) that is defined as g(t)=-(x-1)2+1 for te (0,2. Does an approximation of this function by a Fourier series converge faster for the odd or the even extension. (c) Consider the function h(t) cos2(t)+sin2 (t). Are the coefficients by of the Fourier series of this function equal to 0 for all n? (d) Consider the...
please help me with this MATLAB CODE and
explain to me what each line does and what is used for?
leave your comments as words, not as pictures.
.....................................................................................................................................................................
clear all; close all; % For a script file, you better start with
clear all and close all
% However, for a fucntion, you better NOT to start
% with them
%% End of cell mode example
%% Plot function
t = 0:0.1:5;
x1 = sin(2*5*t); x2 = cos(3*7*t);...
that h(mn ) h ( m)n, h ( ) and that if m < n then h ( m ) < n ( n ) = . Exercise 2.7.4. [Used in Theorem 2.7.1.] Complete the missing part of Step 3 of the proof of Theorem 2.7.1. That is, prove that k is surjective. Exercise 2.7.5. [Used in Theorem 2.7.1.] Let Ri and R2 be ordered fields that satisf We were unable to transcribe this imageWe were unable to transcribe this...