This question somehow addresses the problem, but not from the side I’m looking for.
I’d like to map an array into another, picking only the elements below a certain threshold. Basically a for loop, with an if conditional statement which checks the threshold.
I’m aware of the arrayfun function, but I don’t know a way to put the conditional statement in it without defining a new function.
Is there a way to perform this task with an inline instruction?
解决方案
Maybe this is what you are looking for:
A = (0:49) ./ 50; % Generate the initial array.
B = A( A < 0.5 ); % Map an array into another, picking only the elements below a certain threshold.