フィルターのクリア

Selecting from a range of values from a column matrix

4 ビュー (過去 30 日間)
Austin Ukpebor
Austin Ukpebor 2021 年 10 月 7 日
コメント済み: Austin Ukpebor 2021 年 10 月 7 日
I have a column matrix (398404 x1). I want any values less than 42 between rows 290360 and 380876 to be 5 while values outside those rows remain the same. Please I need help. Thank you.

採用された回答

Walter Roberson
Walter Roberson 2021 年 10 月 7 日
r1 = 290360; r2 = 380876;
extract = YourMatrix(r1:r2);
extract(extract < 42) = 5;
YourMatrix(r1:r2) = extract;
or...
r1 = 290360; r2 = 380876;
rowidx = (1:numel(YourMatrix)).';
mask = rowidx >= r1 & rowidx <= r2 & YourMatrix < 42;
YourMatrix(mask) = 5;
  1 件のコメント
Austin Ukpebor
Austin Ukpebor 2021 年 10 月 7 日
It works! Apart from array indexing, what other areas would you recommend I read up?
Thank you.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLinear Least Squares についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by