Can parallel traversals be done in MATLAB just as in Python?
<p>Using the <code>zip</code> function, Python allows for loops to traverse multiple sequences in parallel.  </p>

<p><code>for (x,y) in zip(List1, List2):</code></p>

<p>Does MATLAB have an equivalent syntax? If not, what is the best way to iterate over two parallel arrays at the same time using MATLAB?</p>

<p>If x and y are column vectors, you can do:</p>

<pre><code>for i=[x';y']
# do stuff with i(1) and i(2)
end
</code></pre>

<p>(with row vectors, just use <code>x</code> and <code>y</code>).</p>

<p>Here is an example run:</p>

<pre class="lang-matlab prettyprint-override"><code>&gt;&gt; x=[1 ; 2; 3;]

x =

     1
     2
     3

&gt;&gt; y=[10 ; 20; 30;]

y =

    10
    20
    30

&gt;&gt; for i=[x';y']
disp(['size of i = ' num2str(size(i)) ', i(1) = ' num2str(i(1)) ', i(2) = ' num2str(i(2))])
end
size of i = 2  1, i(1) = 1, i(2) = 10
size of i = 2  1, i(1) = 2, i(2) = 20
size of i = 2  1, i(1) = 3, i(2) = 30
&gt;&gt; 
</code></pre>
