Split vector by value ranges?
Ältere Kommentare anzeigen
Given:
w=[2,8,3,30,4,50,100,200,4,80,500]
How can I turn the following into a single line of code?
r=w(w>0 & w<10)
s=w(w>10 & w<100)
t=w(w>100 & w<1000)
I tried variations of:
[r,s,t]=w(w>0 & w<10),w(w>10 & w<100),w(w>100 & w<1000)
2 Kommentare
Akzeptierte Antwort
Weitere Antworten (1)
Walter Roberson
am 26 Jan. 2021
[r,s,t] = deal(w(w>0 & w<10),w(w>10 & w<100),w(w>100 & w<1000))
1 Kommentar
Don Kelly
am 28 Jan. 2021
Kategorien
Mehr zu Matrix Indexing 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!