In Java I can directly loop over elements in an array, e.g.:
int[] array = [1,2,3,4];
for (int elem: array){
System.out.println(elem);
}
Instead of looping via indices
int[] array = [1,2,3,4];
for(int i=0; i<array.length; i++){
System.out.println(array[i]);
}
How can I do the same in MATLAB?