How to find result in the same metric ??
2 views (last 30 days)
Show older comments
It wasn’t what I thought it would be. The final result in the variable "fr" has the same value or incorrect . what should i do?
x = rand(100, 2);
col1 = x.data(:,1);
col2 = x.data(:,2);
n = 2;
val = zeros(n,1);
fr = zeros(n,2);
for i=1:n
[val(i) , idA] = min(col2);
col2(idA) = []; % remove the first value
end
fr=col1(idA);
I would like row and colum result of variable fr is like variable val?
0 Comments
Answers (1)
Walter Roberson
on 19 Jun 2021
[val(i) , idA] = min(col2);
You are taking min() of the same thing each time, so you get the same result each time.
2 Comments
Walter Roberson
on 20 Jun 2021
Consider using mink to find the indices of the n minimum entries of the first column and use the indices to index the rows
See Also
Categories
Find more on Descriptive Statistics 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!