Optimizing Minimum Value Search in MATLAB for Scientists

Click For Summary

Discussion Overview

The discussion revolves around finding the minimum value in an array using MATLAB, specifically focusing on implementing a custom loop for this task rather than using built-in functions. The scope includes programming techniques and optimization in MATLAB.

Discussion Character

  • Technical explanation
  • Homework-related

Main Points Raised

  • One participant inquires about implementing an optimization search for finding the minimum value in an array.
  • Another participant suggests using the built-in function [value index] = min(array) as a straightforward solution.
  • A different participant expresses a desire to write their own loop, indicating a lack of familiarity with MATLAB.
  • One reply proposes that to create a custom solution, the participant would need to iterate through the array and track the lowest value, implying the use of a for loop and comparison tests.
  • Another participant points out that if the user is unfamiliar with flow control in MATLAB, the official documentation could be beneficial, providing a link to the relevant page.
  • A hint is given regarding the use of prod(size(MATRIX_A)) for flow control, although its relevance is not fully explained.

Areas of Agreement / Disagreement

There is no consensus on the preferred method for finding the minimum value, as some participants advocate for built-in functions while others prefer a custom implementation approach. The discussion remains unresolved regarding the best method to use.

Contextual Notes

Participants have not fully explored the implications of writing a custom loop versus using built-in functions, and there may be assumptions about the user's familiarity with MATLAB that are not explicitly stated.

Who May Find This Useful

This discussion may be useful for individuals learning MATLAB programming, particularly those interested in implementing custom algorithms for basic tasks like finding minimum values in arrays.

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

  • · Replies 3 ·
Replies
3
Views
5K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 4 ·
Replies
4
Views
7K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 5 ·
Replies
5
Views
4K
Replies
7
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 10 ·
Replies
10
Views
4K
  • · Replies 5 ·
Replies
5
Views
3K