How find rows and columns in matlab
<p>I have variable matrix :</p>

<pre><code>A = [1     2     8     8     1
     4     6     8     1     1
     5     3     1     1     8];
</code></pre>

<p>and I have variable B :</p>

<pre><code>B=[2 3 1 8 8];
</code></pre>

<p>Question is how to find rows and columns (sort by rows) in variable A from variable B.</p>

<p>Example, first index in variable B is 2, and then I want to find value 2 in variable A and get to first rows and columns, and next process until index 5, but if rows and columns has been used so get second position (ex. index 4 &amp; 5 having same value).</p>

<pre><code>rows;
columns;
</code></pre>

<p>Result is:</p>

<pre><code>rows = 1 3 1 1 1
columns = 2 2 1 3 4
</code></pre>