Verifying an Vector composition
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Vinay Killamsetty
am 20 Jun. 2021
Bearbeitet: Scott MacKenzie
am 22 Jun. 2021
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?
0 Kommentare
Akzeptierte Antwort
Weitere Antworten (1)
Scott MacKenzie
am 20 Jun. 2021
Bearbeitet: Scott MacKenzie
am 22 Jun. 2021
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
Siehe auch
Kategorien
Mehr zu Shifting and Sorting Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!