Reputation: 1102
Let's say we have an array numbers
. If any elements in the array are greater than 3, I want to make array
equal nan
.
array = [1 2 3 4 5];
if arrayfun(@greater than 3,array)
array = nan;
end
Upvotes: 0
Views: 241
Reputation: 943
You don't really need arrayfun for this simple job. if any(array > 3); array = nan; end
is all you need.
Upvotes: 2