How to find when the maximum occurs

35 ビュー (過去 30 日間)
Cam B
Cam B 2022 年 3 月 21 日
コメント済み: Zach Ruble 2023 年 9 月 27 日
I am trying to find the time, t, at which the maximum value occurs at. The variable 'maxgiven' displays a 1x5 vector of the maximum values for a set of data. Trying to find the time, t, at which each maximum value is occuring at, which would be labeled 'tmaxgiven'. The test case written belows displays an empty vector. Please use the variable names provided.
maxgiven = [max(y1(:,1)); max(y2(:,1)); max(y3(:,1)); max(y4(:,1)); max(y5(:,1))]
%test case
tmaxgiven = find(t1 == max(y1(:,1)))

採用された回答

Arif Hoq
Arif Hoq 2022 年 3 月 21 日
time=(1:5)';
val1=[10 13 45 23 11]';
val2=[56 23 45 89 23]';
val3=[90 78 12 45 22]';
matrix=[time val1 val2 val3]
matrix = 5×4
1 10 56 90 2 13 23 78 3 45 45 12 4 23 89 45 5 11 23 22
[M I]=max(matrix(:,2:end))
M = 1×3
45 89 90
I = 1×3
3 4 1
I is your time(row) index
  2 件のコメント
Arif Hoq
Arif Hoq 2022 年 3 月 21 日
@Cam B Did my answer solve your problem ?
Zach Ruble
Zach Ruble 2023 年 9 月 27 日
@Arif Hoq It helped solve my problem.
Thanks!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by