Fastest way of generating a logical matrix by given row indices of true values?
<p>What is the most efficient way of generating</p>

<pre><code>&gt;&gt; A

A =

     0     1     1
     1     1     0
     1     0     1
     0     0     0
</code></pre>

<p>with</p>

<pre><code>&gt;&gt; B = [2 3; 1 2; 1 3]

B =

     2     3
     1     2
     1     3
</code></pre>

<p>in MATLAB?</p>

<p>E.g., <code>B(1, :)</code>, which is <code>[2 3]</code>, means that <code>A(2, 1)</code> and <code>A(3, 1)</code> are <code>true</code>. </p>

<p>My attempt still requires one for loop, iterating through <code>B</code>'s row. Is there a loop-free or more efficient way of doing this?</p>