check if values are in multiple ranges

16 Ansichten (letzte 30 Tage)
Sohrab Salimian
Sohrab Salimian am 28 Jan. 2020
Kommentiert: Sohrab Salimian am 28 Jan. 2020
hello, so i have a vector of values a = [1,2,4,5,6]; and I want to know if these are within multiple ragnes. Thus I have a baseline for each range val_bottom = [0, 5, 3, 2]; and i have a ceiling for each vals_top = [5, 10, 8, 12]; . I want to know which of the values in a fall into each range, thus I would like four outputs one for each range. If anyone can help that would be amazing.

Akzeptierte Antwort

Stephen23
Stephen23 am 28 Jan. 2020
>> a = [1,2,4,5,6];
>> val_bottom = [0,5,3,2];
>> vals_top = [5,10,8,12];
>> a(:)>=val_bottom & a(:)<=vals_top
ans =
1 0 0 0
1 0 0 1
1 0 1 1
1 1 1 1
0 1 1 1

Weitere Antworten (0)

Kategorien

Mehr zu Matrices and Arrays 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!

Translated by