How do I find max values in a vector
조회 수: 2 (최근 30일)
이전 댓글 표시
I have a vector like this: v=[1, 3, 5, 2, -4, -3, -1, 2, 3, 1, 2, -3, -2, -4]
I need the max value of every positive sequence and min value of every negative sequence
I need a vector like this a=[5, -4, 3, -4]
thanks for help
댓글 수: 0
답변 (1개)
KSSV
2021년 10월 25일
v=[1, 3, 5, 2, -4, -3, -1, 2, 3, 1, 2, -3, -2, -4] ;
iwant = [max(v(v>0)) min(v(v>0)) max(v(v<0)) min(v(v<0))]
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!