introduction to programming with matlab - Vanderbilt University week-9 assignment 3 solutions

Saddle Points

These solutions are for reference only.

It is recommended that you should solve the assignment and quiz by yourself honestly then only it makes sense to complete the course.

but if you cant figure out some part of it than you can refer these solutions

make sure you understand the solution  

dont just copy paste it


function indices = saddle(M) indices = zeros(0, 2); [rows, columns] = size(M); for row = 1:rows for column = 1 : columns point = M(row, column); if isGreaterThan(point, M(row, :)) && isSmallerThan(point, M(:, column)) indices(end + 1, :) = [row, column]; %#ok<AGROW> end end end end function predicate = isGreaterThan(point, vector) predicate = sum(point >= vector) == length(vector); end function predicate = isSmallerThan(point, vector) predicate = sum(point <= vector) == length(vector); end

main course :