copying matrix values based on another matrix value in MATLAB
<p>Hi I am trying to perform this on MATLAB </p>

<p>A =</p>

<pre><code>64     2     3    61    60     6     7    57
 9    55    54    12    13    51    50    16
17    47    46    20    21    43    42    24
40    26    27    37    36    30    31    33
32    34    35    29    28    38    39    25
41    23    22    44    45    19    18    48
49    15    14    52    53    11    10    56
 8    58    59     5     4    62    63     1
</code></pre>

<p>I want to select values from A based on F</p>

<p>F =</p>

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

<p>I want this output </p>

<p>u =</p>

<pre><code>40    26    27    37    36    30    31    33
41    23    22    44    45    19    18    48
49    15    14    52    53    11    10    56
 8    58    59     5     4    62    63     1
</code></pre>

<p>This means that I want all the values corresponding to '-1' in a matrix. i tried u=A(F==-1) ... but it gives me a single column with all the values like this:</p>

<p>u =</p>

<pre><code>40
41
49
 8
26
23
15
58
27
22
14
59
37
44
52
 5
36
45
53
 4
30
19
11
62
31
18
10
63
33
48
56
 1
</code></pre>