comparing two matrices satisfying two conditions.

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.

 채택된 답변

Thorsten
Thorsten 2015년 11월 9일

0 개 추천

[~, idx] = max(maxLoad);
mtl = min(totalLoad([1:idx-1 idx+1:end]));

댓글 수: 2

Ujwal
Ujwal 2015년 11월 9일
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.
The second output argument of min and max give the index:
[mtl idx_mtl] = min(totalLoad([1:idx-1 idx+1:end]));

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

질문:

2015년 11월 9일

댓글:

2015년 11월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by