フィルターのクリア

how to find maximum value of 2nd column of matrix 22x2?

2 ビュー (過去 30 日間)
Rasha
Rasha 2013 年 12 月 25 日
コメント済み: Rasha 2013 年 12 月 25 日
I have the next matrix A I want to find maximum value of 2nd column of it,
but the matlab didn't accept the step!!!
A = [1 32143;2 1;3 98998;4 45321;5 96856;6 32143;7 9991;8 4343;9 34454;10 9991;11 9991;12 654;13 6798];
[n m] = size(A);
min = min(min(A));
max = max(max(A));
s = 1;
for k = min:max
t = 0;
for i = 1:n
for j = 1:m
if A(i,j) == k
t = t+1;
end
end
end
N(s,:) = [k t];
if t == 0
N(s,:) = N(s-1,:);
s = s-1;
end
s = s+1;
end
[num index] = max(N);
thanks

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 12 月 25 日
編集済み: Azzi Abdelmalek 2013 年 12 月 25 日
[num idx]=max(A(:,2))
  3 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 12 月 25 日
編集済み: Azzi Abdelmalek 2013 年 12 月 25 日
You have used max as a variable
max = max(max(A));
Then used it as a function, Matlab does not recognize it as a function
[num index] = max(N);
Do not use function names as variables; use for example
max_value = max(max(A));
%OR
max_value = max(A(:));
Rasha
Rasha 2013 年 12 月 25 日
yes of course, :)
I didn't observe that
thanks too much

サインインしてコメントする。

その他の回答 (0 件)

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by