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.

댓글 수: 5

Star Strider
Star Strider 2014년 11월 20일
What have you done to code it?
We will help you get your homework code working, but we will not write it for you.
B Ceng
B Ceng 2014년 11월 20일
Honestly, the question is written in such a confusing manner for me. Anything would help because I do not know where to begin..
Star Strider
Star Strider 2014년 11월 20일
It’s not confusing really. Start with Matrices and Arrays, then Matrix Indexing to understand it. (You may also need to read about Special Characters to understand how to do element-wise operations.)
Otherwise, search the MATLAB Documentation for the information you want, for instance ‘absolute value’ and ‘loop’ that you will need to do this particular problem.
Part of using any software is to understand how to use the documentation for it.
B Ceng
B Ceng 2014년 11월 20일
Thank you
Star Strider
Star Strider 2014년 11월 20일
My pleasure!
I perhaps should have posted this as an answer, but it really isn’t one.

댓글을 달려면 로그인하십시오.

 채택된 답변

Image Analyst
Image Analyst 2014년 11월 20일

0 개 추천

Hint: max() and abs(). That's all you need. You can do it in one line (not including the function declaration line).

댓글 수: 1

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)..............
% Add in row offset.
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

질문:

2014년 11월 20일

댓글:

2014년 11월 20일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by