If I am having a symmetric structures vector Eg: A = [a2 a1 a3 a4 a5 a4 a3 a2 a1]
I want to check whether the vector is having a peak value at the center index and the other values are arranged in a decreasing fashion from the center. I.e. a1<a2<a3<a4<a5.
How to check this?

 採用された回答

Matt J
Matt J 2021 年 6 月 20 日
編集済み: Matt J 2021 年 6 月 20 日

1 投票

issorted(A(1:ceil(end/2))) & all(A==flip(A))

1 件のコメント

Vinay Killamsetty
Vinay Killamsetty 2021 年 6 月 22 日
Thank you very much

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

その他の回答 (1 件)

Scott MacKenzie
Scott MacKenzie 2021 年 6 月 20 日
編集済み: Scott MacKenzie 2021 年 6 月 22 日

1 投票

There is probably an easier approach, but I think this works. The result of this expression is 1 if a1<a2<a3<a4<a5, or 0 otherwise
mean(diff(A(1:ceil(end/2))) > 0) == 1

カテゴリ

ヘルプ センター および File Exchange で Shifting and Sorting Matrices についてさらに検索

製品

リリース

R2020a

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by