Condition
显示 更早的评论
Hi,
I have a query.
Generally relational operators are used to check whether some condition is true. i.e. it returns a logical vector. Is it possible that the new vector has the same values as the original vector (based on some conditions). For eg, Suppose there is a vector with 10 elements [say (1,3,2,1,4,6,7,8,5,2)]and i put a condition that the new vector is formed such that it has elements which are only less say 5. How is that possible.?
Regards
采纳的回答
更多回答(1 个)
Adrien Leygue
2011-5-11
0 个投票
Try this:
A = rand(1,10);
B = A(A<0.5);
C = zeros(size(A));
mask = A<0.5;
C(mask) = A(mask);
I think this could provide some answer.
A.
类别
在 帮助中心 和 File Exchange 中查找有关 General Applications 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!