Posted By

eiger_824 on 10/27/14


Tagged

array elements add matlab first k


Versions (?)

Add the first k elements in an array with Matlab


 / Published in: MatLab
 

A simple function in Matlat to add the first k elements in an array

  1. function sum = sumk (array , k)
  2. sum = 0;
  3. for i = 1:k
  4. sum = sum + array(i);
  5. end
  6.  
  7. end

Report this snippet  

You need to login to post a comment.