If i have a simple array in matlab, say:
a = [0 1 2 3 4 5 6 0 0]
How do i constrain the values in that array (if for example i want the maximum value to be 1, so to get to:
a = [0 1 1 1 1 1 1 0 0]
What would be the simplest, most efficient way to do that?
a(a>1) = 1;
This would do what you're asking... you can follow the same pattern for other constraints.
Edit: commenter is correct, fixed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With