フィルターのクリア

How to remove specific numbers from an array?

30 ビュー (過去 30 日間)
Sumanth
Sumanth 2023 年 2 月 9 日
編集済み: Askic V 2023 年 2 月 28 日
lb = [0 0 0 0 0];
ub = [24 24 24 24 24];
How can I remove or not consider certain values in the array? For each 0 - 24 range for 5 different slots, I want to eliminate the numbers 10 to 18.

採用された回答

Askic V
Askic V 2023 年 2 月 9 日
編集済み: Askic V 2023 年 2 月 28 日
If you want to remove certain values from the array, please have a look at this simple example:
v = randi(10,1,20) % generate 20 random integer numbers in interval 0 to 20
v = 1×20
8 3 2 3 2 8 10 7 10 5 4 4 3 7 7 5 7 4 8 10
ind = v>3 & v<7; % find indices of elements in certain interval
v(ind) = [] % remove those elements that fits criteria
v = 1×15
8 3 2 3 2 8 10 7 10 3 7 7 7 8 10
  1 件のコメント
Sumanth
Sumanth 2023 年 2 月 27 日
Thank you so much!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeProblem-Based Optimization Setup についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by