recursiveCol

# recursiveCol - %vector[r c = size(arr%finds the dimensions...

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

function noindex = recursiveCol(arr,index) %Given a matrix of doubles and an index, write a function recursiveCol %that finds the sum of all of the elements in the specified column. Your %function should then delete specified column. If that sum is a valid %column index for the new, smaller matrix, then make another call to %recursiveCol using the new matrix and the sum as inputs. (The validity %of the new index has everything to do with the number of columns in the %smaller matrix.) The index will always be an integer, but it may not %be positive. %The function should terminate when the sum of the current column is not %a valid index for the new, smaller matrix. The function should return %every valid index that was found in the order that they were found. If %the original given index is invalid, the result should be an empty
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: %vector. [r c] = size(arr); %finds the dimensions of the array of numbers if index > c | index <= 0 %terminating condition; if the specified index is greater than the number of columns, then the %result will be an empty vector noindex = ; %empty vector result elseif index > 0 & index <= c %condition to check if the index is greater than 0 (the vector doesn't %exist) and less than or equal to the number of columns total = sum(arr(:,index)); %finds the total sum of the specified column arr(:,index) = ; %eliminates the column that the sum was found noindex = [index recursiveCol(arr,total)]; %clones the original function and concatenates it with the original %index value 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 Tech.

Ask a homework question - tutors are online