My question is: How could I perform something like List comprehension in Matlab similar to Haskell or Python? To accomplish the function in Matlab like below:
for xxx
if condition
expression1;
else
expression2;
end
end
My original aim is to make use of the vectorized operations and reduce the for-loop in my code to make it running faster.
EDIT: My expect to the answer is not necessary something related to the arrayfun, the vectoried operation method is more welcomed.
There is another question related to this question (through the function named "arrayfun"). The anonymous function in Matlab seams to be only 1 line, then how could I write the if-else expression in it ?
Thanks everyone ~~