R language
Create the vectors:
(a) (1, 2, 3, . . . , 19, 20), which contains numbers increase by 1
(b) (20, 19, . . . , 2, 1), which contains numbers decrease by 1
(c) (4, 6, 3) and assign it to the name tmp. For part (d) and (e) look at the help for the function rep.
(d) (4, 6, 3, 4, 6, 3, . . . , 4, 6, 3) where there are 10 occurrences of pattern (4, 6, 3).
(e) (4, 4, . . . , 4, 6, 6, . . . , 6, 3, 3, . . . , 3) where there are 10 occurrences of 4, 20 occurrences of 6 and 30 occurrences of 3.
(f) create a vector of (1, 2, 3, . . . , 19, 20, 19, 18, . . . , 2, 1)
code;
# creating a vector x with values increasing by 1 from 1 to
20
x <- 1:20; x
# creating a vector y with values decreasing by 1 from 20 to
1
y <- 20:1; y
# creating a vector tmp with values 4, 6, 3
tmp <- c(4, 6, 3); tmp
# creating a vector tmp1 with repeating values of tmp, 10
times
tmp1 <- rep(tmp, 10); tmp1
# creating a vector tmp2 with repeating values of 4-> 10
times, 6-> 20 times and 3-> 30 times
tmp2 <- rep(tmp, c(10, 20, 30)); tmp2
# creating a vector z in which first the values increase from 1
to 20 then decrease from 20 to 1
z <- c(1:20, 19:1); z
o/p:
O/p:
For help please comment.
Thank You.
R language Create the vectors: (a) (1, 2, 3, . . . , 19, 20), which...
Use R language pls • Create a list containing 3 vectors: your favorite food (at least 4), your expected grade at the two midterms and the final exam (1 to 100), your date of birth (feel free to lie). • name the vectors: food, grades, DOB • Create a new list just with the grades and the DOB. . Using the previous list, create a new list just with the grades and the food. • Compute the median and the...
MATLAB Create a row vector vC=2:3:38 that has 13 elements. Then, create the following new vectors by assigning elements of vC to the new vectors: (a) A vector (name it vCodd) that contains all the elements with odd index of vC; i.e., vCodd = 2 8 14 ... 38. (b) A vector (name it vCeven) that contains all the elements with even index of vC; i.e., vCeven = 5 11 17 ... 35. In both parts use vectors of odd...
4.) Consider a system in 3-dimensions with basis vectors {v1, v2, vs}, where V 1 0 1 1 0 0 1 U3= 1 -1 0 The operator A when acted upon the basis vector ui gives a new vector X, with AvXy Σ ν X-Σ4υ Please write out the explicit expression for the 3 x 3 matrix A,, which is the operator in the v basis, in terms of ay and numbers (you can't just write v) (10-pts) Now lets...
C++ Language: Do not use namespace Test Case: 3-D vectors Write a templated function, called "add 3d", that can add two const references to 3-d vectors [vector<vector-vector<T>>>]. It should return a new 3-d vector that performed element-wise addition. You cannot use indexing on this problem, instead you must use iterators to access the values of end vector. INPUT OF THE TEST CASE 1 #include <vector> 2 using std: : vector; 3 const vector<double> a{1, 4, -6}; const vector<double> b{3, 6,...
Python Language Only!!!! Python Language Only!!!! Python Language Only!!!! Python 3 is used. A. Write a function named smaller that accepts two arguments: a list, and a number n. Assume that the list contains numbers. The function should display all numbers in the list that are smaller than the number n. Write a code that declares and initializes a list of numbers and a variable number and pass them to the function to test it. Please see the outcome below:...
Python Language Only!!!! Python Language Only!!!! Python Language Only!!!! Python 3 is used. A. Write a function named smaller that accepts two arguments: a list, and a number n. Assume that the list contains numbers. The function should display all numbers in the list that are smaller than the number n. Write a code that declares and initializes a list of numbers and a variable number and pass them to the function to test it. Please see the outcome below:...
Several vectors in the x-y plane are shown in the figure with their tails at the origin of the coordinate system and with a label at their heads. Two of these vectors are given in terms of the unit-vectors i and j as P = (2.20i + 5.30j) and Q = (-5.30i + 5.40j), where the numbers are measured in meters. Identify vectors P and Q in the figure. The label of vector Q on the figure is ... A:...
10 Vectors Exercise 2.3. Create the following vectors in R using seq) and/or rep(). A of noititiionl nA drim2 M.a8 201deeV M.W LWWi enige seq(from,to1|2, (i) 1, 1.5, 2, 2.5,..., 12/29 at ijuomo lins 101 toio1tt ot.noitoubotnl 0S (ii) 1, 8, 27, 64, . . . , 1000.OLSvep (1:5, ayth. oub (iii) 1, 0, 3, 0, 5, 0, 7, . . . , 0, 49. s b 1ot S tA ot no weight Set Flome fosa u B0E1os welght lo00)
Algebraic Vectors in 3 Dimension iven OA(1.3, 5) iiii = (-2,4,-6) vectors 2 Express each vectors as a 3 Determine the opposite vector of oc - (4.-8 0 located e frontback, letnght, upperower standard unit vector form. oC 4. Determine the magnitude of each vector 5. Determine the unit vectors in 6 Express the following as a component form of loAl OA + 08-20で los) 10리 7. Determine 8. Point D is (1,2,3) and9 Point E if (3,5,7), determine by...
Problem 5 Create the following matrix by typing elements explicitly one command. Do not type individual 0 00 0 0 o o 0 0 0 0 0 1 2 3 F=0 01 10 20 0 0 2 8 26 0 0 3 6 32 E 0 045 6 0 0 7 8 9 Problem 6 Create two row vectors: a -4 10 0.5 1.8 -2.3 7, b [0.7 9 -53-0.6 12 (a) Use the two vectors in a MATLAB command...