recursiveCol

recursiveCol - %a valid index for the new, smaller matrix....

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

View Full Document Right Arrow Icon
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
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: %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 %vector. [r c] = size(arr); %finds the dimensions of the array of numbers if index > c %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 total = sum(arr(:,index)); arr(:,index) = ; noindex = [index recursiveCol(arr,total)]; end end...
View Full Document

Ask a homework question - tutors are online