comparing two matrices satisfying two conditions.

2 views (last 30 days)
Hi, I am new in matlab and unable to solve a problem.
Problem goes like this:
I have two matrices named: total_load and maxLoad: both of them 16*1 matrix.
I want to know BestRoute. The condition is to find (min(total_load) && ~max(maxLoad));
Which mean I want to find minumum in total_load matrix but excluding row which contains maximum in maxLoad matrix. I want to display BestRoute in terms of position of total_load matrix.

Accepted Answer

Thorsten
Thorsten on 9 Nov 2015
[~, idx] = max(maxLoad);
mtl = min(totalLoad([1:idx-1 idx+1:end]));
  2 Comments
Ujwal
Ujwal on 9 Nov 2015
Thank you for the solution. I am pleased but one more question please if you can reply. I also want to display the position of 'mtl' which exists in matrix total_load. Thank you.
Thorsten
Thorsten on 9 Nov 2015
The second output argument of min and max give the index:
[mtl idx_mtl] = min(totalLoad([1:idx-1 idx+1:end]));

Sign in to comment.

More Answers (0)

Categories

Find more on Operators and Elementary Operations 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!