It is inferred from the last line of question that this is asked in MATLAB
For making a new vector with two copies Use the following command
y=[x x]
we write our new elements inside [] to create a new vector.
For elements of x with odd indices use
z=x(1:2:end)
(for even do this x(2:2:end) )
Understand this notation x(a:b:c) this will return vector with elements of x indices from a to c with the step of b. Means if b=2 we will get every 2nd element if b=3 we will get every third element. If we don't specify anything like x(a:c) it will be like b=1 and will return all elements from indices a to c. end is used to specify to go till the last element.
w=[0 x(1:4) 7 x(5:end) 12]
A similar concept that was used to create y and z is used to create w. First, we started with element 0 and then added element of x from 1 to 4 than inserted 7. than added all remaining element of x using x(5:end) and finally 12 at the end.
MATLAB code:
x = randi([-9,9],1,8)
y=[x x]
z=x(1:2:end)
w=[0 x(1:4) 7 x(5:end) 12]
given a row vector x create each of the following row vectors as indicated y is...
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...
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...
given a size N, create a row vector x= [x1,x2,....,xN] which contains the first N terms of the below sequence: x1=2 xi+1=3-xi you must use a for loop to generate the elements in x. this is done in MATLAB
In Matlab write a script that does the following. 1. Creates a row vector v = [3, 6, 9, 9, 15], and then manipulates v to create each of the following vectors (and then displays the result of each): (a) a = [9, 36, 81, 81, 225] (b) b = [ 1 3 , 1 6 , 1 9 , 1 9 , 1 15 ] (c) c = [1, 2, 3, 3, 5] (d) d = [15, 9, 9,...
Each of the following vectors is given in terms of its x and y components. Find the magnitude of each vector and the angle it makes with respect to the +x axis. 1) AxAx = -1, AyAy = -6. Find the magnitude of this vector. (Express your answer to two significant figures.) 2) AxAx = -1, AyAy = -6. Find the angle this vector makes with respect to the +x axis. Use value from -180∘∘ to +180 ∘∘. (Express your...
Matlab problem
A vector, x, containing values between 0 and 5 is generated randomly below. % the length of x is also determined at random. % set up a "for" loop to run over all elements of x - use the "length" command % inside the "for" loop, use a "switch" construct to find the odd values % and the even values (including zero) - use two "case" commands inside the "case" for the odd values, use an "if" so...
QUESTION 1 Given two double variables named x and y, which of the following statements could you use to initialize both variables to a value of 0.0? a. x | y = 0.0; b. x = y = 0.0; c. x, y = 0.0; d. none of the above 1 points QUESTION 2 When you use a range-based for loop with a vector, you a. can avoid out of bounds access b. must still use a counter variable c....
C++ Assignment - Only Implementation file( VectorDouble.cpp file) required. The header file is already given. Please help, thumbs up guaranteed. Chapter 8 discussed vectors, which are like arrays that can grow in size. Suppose that vectors were not defined in C++. Define a class called VectorDoublethat is like a class for a vector with base type double. Your class VectorDoublewill have a private member variable for a dynamic array of doubles. It will also have two member variables of type...
Create the abstract data type IntSet used to implement a mathematical set of non-negative integers (includes zero). Each object of class IntSet can keep track of whether integers are in the set or not. Implement as follows. A set is to be represented internally as a bool array containing true and false. For example, if you call the array set, then set[num] is true if the integer num is in the set, false if num is not in the set....
After the header, each line of the database file rebase210.txt contains the name of a restriction enzyme and possible DNA sites the enzyme may cut (cut location is indicated by a ‘) in the following format: enzyme_acronym/recognition_sequence/…/recognition_sequence// For instance the first few lines of rebase210.txt are: AanI/TTA'TAA// AarI/CACCTGCNNNN'NNNN/'NNNNNNNNGCAGGTG// AasI/GACNNNN'NNGTC// AatII/GACGT'C// AbsI/CC'TCGAGG// AccI/GT'MKAC// AccII/CG'CG// AccIII/T'CCGGA// Acc16I/TGC'GCA// Acc36I/ACCTGCNNNN'NNNN/'NNNNNNNNGCAGGT// … That means that each line contains one enzyme acronym associated with one or more recognition sequences. For example on line 2:The enzyme acronym...