i need it in matlab language please, not C++ neither java Given any sized vector
ID: 1940343 • Letter: I
Question
i need it in matlab language please, not C++ neither java
Given any sized vector, x, of positive and negative numbers determine the sum of the positive elements of the vector. Test your program using the vector: x - [15, -6, 0, 8, -2, 5, 4, -10, 0.5, 3, 1, -8, 11, 7, 6, -4, 9]Explanation / Answer
x = [15 -6 0 8 -2 5 4 -10 0.5 3 1 -8 11 7 6 -4 9]; positive = x>0; sum(x(positive)) The first line of code is just initializing your vector. commas or spaces may be use to make a vector. The next line is creating a variable "positive" which stores all elements of x that are greater than 0. The last line calls the positive elements of x and sums them all together.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.