recurSum - %recursive vectors as well out = vec(1);...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
function out = recurSum(vec) %Given a 1xN array of scalars (a vector), write a function recurSum that %recursively sums the elements of the input array. Your function should %then return this sum. An empty vector ([]) has a sum of 0. %usage: out = recurSum(vec) if ~isempty(vec) %condition to check if the original vector is empty and all of the
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: %recursive vectors as well out = vec(1); %assigns the output to the first value of the vector vec(1) = ; %eliminates the first value of the vector; terminating condition out = out + recurSum(vec); %finds the sum of the recur else out = 0; end end...
View Full Document

This note was uploaded on 10/21/2010 for the course CS 1371 taught by Professor Stallworth during the Spring '08 term at Georgia Institute of Technology.

Ask a homework question - tutors are online