BASICS - sum part of vector - MATLAB Cody - MATLAB Central

Problem 43144. BASICS - sum part of vector

Difficulty:Rate

Please make a function, where as input you get vector "x" and and vector "c", where in "c" vector you get indexes to sum. Example:

x=[-1 2 3 4 7 9]
c=[1 4 6]
y= x(1)+ x(4) + x(6) = -1 + 4 + 9 = 12

Solution Stats

67.73% Correct | 32.27% Incorrect
Last Solution submitted on Jun 10, 2025

Problem Comments

Solution Comments

Show comments
Why should you share code?
In a discussion on LInkedin about my recent blog post, Do these...
3
6

Problem Recent Solvers342

Suggested Problems

More from this Author12

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!