MATLAB Optimizing Minimum Value Search in MATLAB for Scientists

AI Thread Summary
To find the minimum value in an array in MATLAB, a custom loop can be implemented by iterating through the array and tracking the lowest value found. This requires using a for loop and comparison tests to determine the minimum. For those unfamiliar with MATLAB, the official documentation provides useful guidance on flow control and loops. Additionally, MATLAB's built-in help function can be accessed by typing "help <FUNCTION_NAME>" to get information on specific functions. A suggestion for managing array dimensions is to use "prod(size(MATRIX_A))" to assist with flow control during the iteration.
Juanka
Messages
37
Reaction score
0
I got a quick question, let's say I have an array of numbers for example [ 9 3 2 7 1 8 ]
and I want to find the minimum value ie: for this example it would be 1. How could I implement an optimization search like this??
 
Physics news on Phys.org
Code:
[value index] = min(array)
 
I was looking for a way which I could write my own loop, I just am not familiar with MATLAB yet.
 
Well if you want to reinvent the wheel, you'll need to iterate through the list and keep track of the current lowest value...so to me that says for loop, comparison tests...
 
If you don't yet know how to do flow control in MATLAB, their documentation page is quite helpful:
http://www.mathworks.com/help/techdoc/learn_matlab/f4-1931.html

NOTE: You can bring up the built-in help in MATLAB for any function by typing
>> help <FUNCTION_NAME>

HINT: prod(size(MATRIX_A)) may help you with your flow control...
 
Last edited by a moderator:

Similar threads

Back
Top