How to split vector according to conditions?
Ältere Kommentare anzeigen
Hello,
I have a quite technical question concerning vectors splitting
Consider I have a vector containing groups of successive values e.g. :
V = [1 2 34 35 36 102 103 104]
This vectors contains the coordinates of another bigger vectors satisfying a specific condition
(e.g. the values of X smaller than 20: X(1) = 13, X(2) = 12, X(34) = 15, X(35) = 3, X(36) = 9, X(102) = 19, X(103) = 12, X(104) = 11)
I would like to split the vector V into (in this case 3) different parts of consecutive values (here [1 2] , [34 35 36] and [102 103 104])
in order to, then, apply a condition for each part, like for example find the smallest value of X in each of these parts (here X(2), X(35),X(104))
Do you have any ideas of how to accomplish this without using any "for" loop?
Thanks a lot!
Akzeptierte Antwort
Weitere Antworten (1)
David Hill
am 2 Jun. 2020
Not exactly sure what you are trying to do.
m=[min(X(V(1:2))),min(X(V(3:5))),min(X(V(6:8)))];
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!