- [M,I] = max(_) finds the indices of the maximum values of A and returns them in output vector I, using any of the input arguments in the previous syntaxes. If there are several identical maximum values, then max returns the index of the first one.
function to find arg max
22 ビュー (過去 30 日間)
古いコメントを表示
Hello, i have a problem. please help
we have x1, x2, x3, x4 are different functions of ' t ' and f1, f2, f3, f4 are also different.
t=1:50;
C1=f1(x1)
C2=f2(x2)
C3=f3(x3)
C4=f4(x4)
for t=1:50
C=max([C1 C2 C3 C4])
end
how to find x which cause C max?
0 件のコメント
回答 (1 件)
Star Strider
2014 年 11 月 28 日
You can get the index of the maximum returned by max by asking the function to return it. From the documentation:
2 件のコメント
Star Strider
2014 年 11 月 28 日
Your question and code lack some necessary information. You are iterating through ‘t’, but your ‘f1...f4’ functions are of ‘x1...x4’ which are different functions of ‘t’ but not explicitly so in the code you posted to create ‘C1...C4’.
I got the impression that you intended to create one value for ‘C1...C4’ in each iteration of your loop, so then each ‘C1...C4’ is a scalar.
I inferred:
for t = 1:50
C1=f1(x1(t));
C2=f2(x2(t));
C3=f3(x3(t));
C4=f4(x4(t));
[C,I]=max([C1 C2 C3 C4]);
Cmax(t) = [C I];
end
so that for every value of ‘t’ you would get the maximum as ‘C’ and the function that produced it in ‘I’.
If that is not what you are doing in your loop, you need to provide a more specific description.
参考
カテゴリ
Help Center および File Exchange で Get Started with Phased Array System Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!