フィルターのクリア

one-to-one mapping of a vector based on error bounds

1 回表示 (過去 30 日間)
Jonah Foley
Jonah Foley 2020 年 3 月 26 日
編集済み: David Goodmanson 2020 年 3 月 30 日
lets say I have the vector x = [-13, -13.2, -13.7, -11.6, -8.7, -6,5, -6.7, -6.6, -6.2, -5.9]
and I would like to make the following mappings, based upon some error bounds (i.e cleaning up the data):
-14 < x < -8 --> x = -13
-8 < x < -2 --> x = -6
so that under the mapping x becomes:
x = [-13, -13, -13, -13, -13, -6, -6, -6, -6, -6]
I have been able to achieve this using a for loop, but I'm assuming there is a faster/more efficient way to do this. Any ideas? Thanks

回答 (1 件)

David Goodmanson
David Goodmanson 2020 年 3 月 30 日
編集済み: David Goodmanson 2020 年 3 月 30 日
Hi Jonah,
x(-14 < x & x < -8) = -13;
x(-8 < x & x < -2) = -6;
What happens if x =8? Looks like you could use <= in place of one of the two <

製品

Community Treasure Hunt

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

Start Hunting!

Translated by