How to find matrix values by column and row indexes
3 views (last 30 days)
Show older comments
Hi,
I have a large m x n matrix, let's say "A" and I would like to find the location indexes of minimum values(negative or positive) in each column and confirm that location. So, I used sth like this
>> temp0=A
>> temp1=abs(A)
>> sorted_mat=sort(temp1,1,'ascend');
>> [rw0, col0]=find(temp1==sorted_mat(1,:));
>> For i=1:size(rw0,1)
>> min_values(i)=temp0(rw0(i),col0(i))
>> end
However, I would like to use indexes directly. I had this method
>> temp0=A
>> temp1=abs(A)
>> sorted_mat=sort(temp1,1,'ascend');
>> [rw0, col0]=find(temp1==sorted_mat(1,:));
>> min_values=nonzeros(A(rw0,col0).*eye(size(rw0,1))
The problem with this method is that it doesn't work with really large numbers like 60k. Do you have any idea to solve it by indexes? I don't like using for loops. :)
0 Comments
Answers (1)
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!