How do I limit the values in an array?
319 次查看(过去 30 天)
显示 更早的评论
This should be an easy one.
If I have an array with...
0.203 0.506 0.167 0.904 1.671 5.247 0.037 0.679
How do I amend the individual values within the array that are greater than 1 and set them to 1?
e.g.
0.203 0.506 0.167 0.904 1.000 1.000 0.037 0.679
Thanks!
0 个评论
采纳的回答
更多回答(1 个)
Jan Siegmund
2020-5-27
编辑:Jan Siegmund
2020-5-27
There is also a matlab function doing this:
A = min(A,1);
It takes A if A is the minimum of the two and 1 if 1 is the minimum of the two.
2 个评论
Walter Roberson
2020-11-30
min(randn(3,3),1) works fine when I test it. Perhaps you accidentally defined min as a variable
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Multidimensional Arrays 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!