X=[1 3 4 15 8 5 3 10 15 21 6 9 18] Write a matlab program that will add all the
ID: 2993471 • Letter: X
Question
X=[1 3 4 15 8 5 3 10 15 21 6 9 18]
Write a matlab program that will add all the numbers corresponding to the even indices of an array. For instance if the array x was X=[1,3,5,10], then it should return 13 (=3+10). Use that program to find the sum of all even integers from 1 to 17. write the program so that it is flexible. That is, you should be able to invoke your program from the command window as follows:
>>y=addeven(x)
where x is the input vector, and y is the sum of all the numbers corresponding to the even indices of x
Explanation / Answer
X=[1 3 4 15 8 5 3 10 15 21 6 9 18] Write a matlab program that will add all the
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.