the function should find the min value in each row, when I run the code it doesnt print the correct answer. Anyone know whats wrong?

2 views (last 30 days)
Alia Alkaabi
Alia Alkaabi on 18 Nov 2021
Edited: Adam Danz on 19 Nov 2021
the function should find the min value in each row, when I run the code it doesnt print the correct answer. Anyone know whats wrong?

Answers (1)

Adam Danz
Adam Danz on 18 Nov 2021
The function returns "A" which is the entire matrix. If you want it to return the minimum value, it should return "min".
However, you shouldn't use "min" as a variable name, even if it's in a function with its own workspace that doesn't use the min function. Suppose you want to touble shoot the function in debug mode and you want to compute the min of "A" using min(A(:)), well you can't because min is a variable name.
Additionally, entering values using input without any constraints or input checks is very prone to errors. I suggest using a uitable or instructing the user to enter a variable that already contains the matrix values.

Tags

Community Treasure Hunt

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

Start Hunting!