Maximum absolute value in array

57 ビュー (過去 30 日間)
Serina Robbins
Serina Robbins 2021 年 3 月 23 日
編集済み: Jan 2021 年 3 月 23 日
I have a formula carry out a calculation that gives me positive and negative numbers (which is is supposed to) that correspond to an alpha angle. How can I find the maximum asbsolute value and find its corresponding alpha?
My code it
By = round((Ey-(FGH.*sind(gamma))),5);
Bymax = max(abs(By))
indexes = find(By == Bymax);
angleBy = alpha(indexes)
Where my Bymax is originally negative but the abs turns it positive. Now I need to find teh corresponding alpha to the Bymax.
It gives me:
angleBy =
1×0 empty double row vector
I tried with another force I have that the magnitude is already a positive number.. the code looks like:
Bz = Ez+(FGH.*cosd(gamma));
Bzmax = max(abs(Bz))
indexes = find(Bz == Bzmax);
angleBz = alpha(indexes)
And that gives me:
Bzmax =
3801.5
angleBz =
8.686
Which is what I want.
What am I doing wrong?

回答 (1 件)

Jan
Jan 2021 年 3 月 23 日
編集済み: Jan 2021 年 3 月 23 日
Use the 2nd output of the max() command:
[Bymax, index] = max(abs(By))
By(index)

カテゴリ

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

タグ

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by