How to copy the content of particular location in matrix when it is in for loop
<p>Here is the below code in matlab. I am trying to copy the contents of the matrix location a{2,3}(2 row ,3 column) if there exists else I want to copy the contents of the location a{1,3} (1st row, 3rd column).But it is checking only for a{2,3} when it comes to a{1,3} it is throwing the error</p>

<pre><code>data759c = [1 1 1 1 1]' and final = [1 1 1 0 1]' for 2X3
                                    [1 1 1 1 1]' for 1X3

for i = 1:size(final,2)
s1 = (data759c(:,1)== final(:,i));
a = tabulate(s1);
if (size(a) == a{1,3})
  b(i) = a{1,3}(1);
else 
b(i) = a{2,3}(1);  
end
end

a will be either 

1  4  80
0  1  20

0r 

1  5  100 

Index exceeds matrix dimensions.

Error in wmojvot (line 22)
b(i) = a{2,3}(1);
</code></pre>

<p>can any one help why I am getting the error</p>