Optimizing Minimum Value Search in MATLAB for Scientists

Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
4 replies · 4K views
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: