Hi. I have a 4 by 4 matrix and I want to find the minimum of each row and also want to find where that minimum is located in each row. Folowing is what I have done.
a = [ 1 2 3 0; 7 5 4 6; 9 8 10 11; 12 13 14 15];
mina = min(a(h,:));
ok = find(a(h,:)== mina);
CG(:,h) = [h,ok];
When I run this I get the out put CG Which finds me the minimum value in each row along with its location in corresponding row.
Now I want to do the same to a much bigger matrix. Now the size of matrix "a" is 75*75. But when I run the code above, I get the error which says : "Subscripted assignment dimension mismatch." I believe the reason for that is there are two minimums in some of the rows. For example the minimum value in row one is 0. But there are two zeros in row one so MATLAB is having hard time finding which location to give as out put. However it is not important for me which location of zero it gives to me. So the question is how do I manipulate my code or my matrix to get the output that I want ( the minimum value and its location)? The code must somehow work for all rows and it also should work if there are more than two equal minimum values in any row!
Thanks in advance