Change the element of the vector with respect to the element of the direction vector
If the element of the direction vector is 2, then the new element of the vector is two times the corresponding element in the vector.
If the element of the direction vector is 1, then the new element of the vector is two times the corresponding element in the vector minus one.
Attention: 'if' can not be used
Example
direction vector d = [1 2 2 2 1 2 1 2] vector = [1 2 3 4 5 6 7 8] new_vector = [1 4 6 8 9 12 13 16]
Solution Stats
Problem Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers95
Suggested Problems
-
Sum of diagonal of a square matrix
1637 Solvers
-
Make a run-length companion vector
657 Solvers
-
440 Solvers
-
Find the dimensions of a matrix
559 Solvers
-
Change the first and last diagonal element of the identity matrix to zero
160 Solvers
More from this Author21
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!