# MATLAB question involving matrices

37 views (last 30 days)
B Ceng on 20 Nov 2014
Commented: Image Analyst on 25 Sep 2021
Write a MATLAB function that takes a matrix, a row number and a column number. Beginning with the row number passed to the function, scan down the column passed to the function and return the row number that contains the largest absolute value in the column. For example if your matrix is
and you pass row 2, column 2, the function should return 3. Row 3 has the largest absolute value in column 2 including and below row 2.
Star Strider on 20 Nov 2014
My pleasure!
I perhaps should have posted this as an answer, but it really isn’t one.

Image Analyst on 20 Nov 2014
Hint: max() and abs(). That's all you need. You can do it in one line (not including the function declaration line).
Image Analyst on 20 Nov 2014
Because you have not said it's solved yet, I assume you're still having difficulty. Here's a little bit more:
function rowOfMax = GetRowMaxes(matrix, row, col)
thisColumn = matrix(row:end, col)
[~, rowOfMax] = max(abs(thisColumn)..............
rowOfMax = rowOfMax + ro.................
It's virtually done. A smart engineer like yourself should have no trouble finishing it - it's only a few characters to complete now. Let me know if you can or can't solve it now.

yalla ahkil reddy on 25 Sep 2021
Edited: Walter Roberson on 25 Sep 2021
function rowOfMax = GetRowMaxes(matrix, row, col)
thisColumn = matrix(row:end, col)
[~, rowOfMax] = max(abs(thisColumn)..............
rowOfMax = rowOfMax + ro.................
Image Analyst on 25 Sep 2021
@yalla ahkil reddy this looks identical to my answer. Did I make some typo that you had to correct? You didn't say how this is different. All I can see is that you added a tab before my comment.