Find Min/Max Value of a Column in a Matrix
10 次查看(过去 30 天)
显示 更早的评论
Hello and Happy Christmas. i have a Variable Buff that is a 231x3 Matrix. My Code looks like this:
Buff = zeros(numel(1286:10:1486)*numel(873:10:973),3);
Ctr = 1;
for step1 = 1286:10:1486
for step2=873:10:973
Main
Buff(Ctr, 1) = step2;
Buff(Ctr, 2) = step1;
Buff(Ctr, 3) = J_Bolzen;
Ctr = Ctr+1;
end
end
save test.dat Buff;
So i have 3 Columns, Column1=step2, Column2=step1 and Column3=J_Bolzen. Now i want find the min Value of the Column3 and the associated Position in the Matrix ( Row and Column ). My first attempt was:
[r c] =find(Buff==min(Buff(:)))
but it looks for the min value of the whole Matrix. It should looks for the min value of Column3 of the Matrix Buff and give the output for that min value and their position in the Matrix
Thanks Guys :-D
0 个评论
采纳的回答
vipul utsav
2012-12-25
[r c] =find(Buff==min(Buff(:,3)))
1 个评论
Walter Roberson
2012-12-25
This will return 1 as the column instead of the 3 reflecting the origin in column 3.
更多回答(2 个)
Walter Roberson
2012-12-25
[minval, minidx] = min(Buff(:,3));
The minimum value would be minval, and the position would be (minidx, 3)
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Christmas / Winter 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!