Finding Min Value in array with changing condition

3 Ansichten (letzte 30 Tage)
Erel Kasirga
Erel Kasirga am 29 Sep. 2019
Beantwortet: Jos (10584) am 29 Sep. 2019
Hello guys,
I got a matrixs which are like ;
in this changable conditions I want to find the min value.
For example;
a= [1 0 0 0 1]
min cost = 5776 according to matrix a

Antworten (1)

Jos (10584)
Jos (10584) am 29 Sep. 2019
tf = a == 1 % create a logical array
temp = cost(tf) % logical indexing to retrieve certain values
mincost = min(temp) % use a dedicated function to find th minimum value
I leave it to you to make this a single statement!




Community Treasure Hunt

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

Start Hunting!

Translated by