I have a range of values between 8e6 and 10e6 distributed in a 1000-element array.
the issue is that I want to add a value if the value is greater than 9e6.
plese give me a suggestion

 Réponse acceptée

Torsten
Torsten le 17 Jan 2023
Modifié(e) : Torsten le 17 Jan 2023
x = 8e6 + 2e6*rand(1,1000)
x = 1×1000
1.0e+06 * 8.9245 8.9990 8.8056 9.1550 8.7082 8.4802 9.8895 9.1387 8.6755 9.9939 9.5333 8.1495 9.4403 9.7444 8.8806 8.7724 9.7467 8.1353 8.4268 8.4135 8.5413 9.8195 9.3468 8.0006 9.8938 8.5222 8.9490 8.2695 9.4282 8.9224
value = 3e5;
x(x>9e6) = x(x>9e6) + value;
x
x = 1×1000
1.0e+07 * 0.8924 0.8999 0.8806 0.9455 0.8708 0.8480 1.0189 0.9439 0.8675 1.0294 0.9833 0.8149 0.9740 1.0044 0.8881 0.8772 1.0047 0.8135 0.8427 0.8413 0.8541 1.0120 0.9647 0.8001 1.0194 0.8522 0.8949 0.8270 0.9728 0.8922

Plus de réponses (0)

Catégories

Produits

Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by