# Question: Create a function that takes a generic matrix, x, and finds the smallest value in the matrix.The function must work for matrices of any size and dimension.

조회 수: 2(최근 30일)
Gurinder Punni 2020년 1월 31일
편집: James Tursa 2020년 1월 31일
I had a similar question to this eariler in which you were told to take inputs z and x from a function and create a matrix of dimension x or z, whichever is larger.
i was told to do something like this:
x = -100:100;
z = -100:100;
myMatrix = randi(100, max(x,z));
do i do the same here but replace the max with min?
thanks for the help.
##### 댓글 수: 1표시숨기기 없음
Geoff Hayes 2020년 1월 31일
Gurinder - no, this question is different from the previous one. It is asking you to create a function whose input is a matrix (of any dimension) and the function then finds (and presumably returns) the smalles value in the matrix. So if the matrix were
[6 2 3;
4 5 1]
then your function (when passed this matrix) would return 1 since that is the smallest value in the matrix.

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

### 채택된 답변

James Tursa 2020년 1월 31일
편집: James Tursa 2020년 1월 31일
Hint: First reshape the input x array into a 1D vector and work with that inside your function.

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

### 범주

Find more on Resizing and Reshaping Matrices in Help Center and File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by