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?
1 view (last 30 days)
Show older comments
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?
0 Comments
Answers (1)
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.
0 Comments
See Also
Categories
Find more on Loops and Conditional Statements 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!