Create a vector (name it vctC) that has 12 elements of which the first is 5, the
ID: 2085383 • Letter: C
Question
Create a vector (name it vctC) that has 12 elements of which the first is 5, the increment is 4 and the last element is 49. Then, by assigning elements of vctC to new vectors, create the following two vectors: (a) A vector (name it Codd) that contains all the elements with odd index of vctC, i.e., Codd = 5 13 21 45. (b) A vector (name it Ceven) that contains all the elements with even index of vct, i.e., Ceven = 9 17 25 49. In both parts use vectors of odd and even numbers for the index of Codd and Ceven, respectively. Do not type the elements of the vectors explicitly.Explanation / Answer
In MATLAB
vctC = 5 9 13 17 21 25 29 33 37 41 45 49
Codd = vctC(1:2:length(vctC))
Codd = 5 13 21 29 37 45
Ceven = vctC(2:2:length(vctC))
Ceven = 9 17 25 33 41 49
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.